One of the most used features of every Analytics plugin is the ability to exclude logged in and especially admin users from being tracked in Google Analytics reports.
As Google Tag Manager goes beyond being an analytical tool, users are able to exclude not only Google Analytics tags but eventually every tag that is included in Google Tag Manager. Using this your activity on your site won’t show up in Analytics reports, you won’t be collected using any remarketing pixel and you won’t be included in any conversion report ruining your real CPA in marketing tools.
My Google Tag Manager for WordPress plugin does not include any feature which prevents the GTM container code from being deployed on each of your pages, instead of it gives you some fancy Data Layer variables which can help you to create trigger exceptions.
Remember: we have to describe the case when you do NOT want to trigger certain tags. This means you have to think of your trigger in the reverse way. When the trigger conditions are being met during page load, the connected tags will not activate.
visitorLoginState is a very simple Data Layer variable: the valueÂ logged-in means someone is logged in to your site regardless of the user level. The valueÂ logged-out means that an anonymous user is on your site. You can read the value using a Data Layer variable in GTM:
In many cases a logged in user means an admin or an editor on the site which is enough to create a trigger:
There are however cases where this is not enough especially when you are using WooCommerce where your customers are being logged in as special WordPress users without access to the admin area. In this or similar cases you will need to identify the user level (aka. user role) of the logged in user.
The Data Layer variable visitorType can help you to get this info. Create a new variable in GTM to access:
If there is no logged in user on your site, the valueÂ visitor-logged-out will indicate that state. If a WordPress user is logged in, the name of the role of the logged in user will be included. For admin this will be administrator, for lower level users this can be something else like editor. Using this info you can create a trigger that matches only certain user role:
If you want to exclude other user roles you can use ‘matching regex (ignore case)’ instead of ‘equals’ and you can list the excluded roles using pipes: administrator|editor|whatever-userrole
Exclude but not while debugging
I usually use a slightly modified trigger to exclude admins. As I am usually an admin too logged in to a site to be able to configure the plugin, I do not want to be excluded while testing a new or modified Google Tag Manager container setup. This is because I would like to see whether tags are being fired while I keep being logged in on the WP site.
To achieve this I usually enable the Debug Mode built in variable in Google Tag Manager and include it in the exclude trigger:
This built in variable will evaluate to true while you turn on preview mode on the GTM website.Â Now you can include one more rule in your triggers:
Add your exception trigger to tags
Now you only have to add this newly created trigger to each of your tags as an exception trigger: