To prevent a Tag from firing in Google Tag Manager, you can:
-
Delete the Tag
-
Remove all Triggers from the Tag
-
Add an Exception Trigger to the Tag
The third option is usually the best if the blocking is just temporary. Exceptions are what used to be called blocking rules in the first version of GTM. To add them is easy enough. In the Fire On step of Tag creation, you can click Create Exceptions, and choose the Trigger that will block this Tag from firing.
However, creating an Exception can lead to confusion, as you have to pick a Trigger type for the exception! But you just wanted to block a Tag from firing; what’s with this Trigger type nonsense?!
The Simmer Newsletter
Follow this link to subscribe to the Simmer Newsletter! Stay up-to-date with the latest content from Simo Ahava and the Simmer online course platform.
Tip 29: Event of an Exception must match Event of the Tag
Every single Tag needs an Event to fire. An Event, in the GTM world, is a special event
key that is pushed into dataLayer
, either automatically by Google Tag Manager, or manually by the website developer:
window.dataLayer.push({
'event' : 'triggerSomeTag',
'money' : 'lots'
});
When an event
key is pushed into dataLayer
, GTM goes through all Triggers attached to Tags, and looks for Triggers which respond to this Event.
If such a Trigger is found, and if any other Trigger conditions pass, then the Tag can happily fire.
If you want to block a Tag from firing, you will essentially need to create an Exception for every single Event you want to prevent the Tag from firing on - individually. So let’s say you have a Tag which fires on Page View, Click, and Form, and you want to block it from firing on Page View and Click, but you still want it to respond to a Form submission. The Trigger you’d need to create as an Exception looks like this:
Now, when you add this Trigger as an Exception to a Tag, the following will happen:
-
Upon Page View (i.e. when the container snippet loads), GTM finds the Event name gtm.js (Page View Event) in the Exception Trigger and prevents the Tag from firing.
-
Upon a Click Event, GTM finds the Event name gtm.click in the Exception Trigger and prevents the Tag from firing.
-
Upon a Form Submit Event, GTM does not find the Event name gtm.formSubmit in the Exception Trigger, and the Tag fires
So as you can see, an Exception always wins against the corresponding Trigger. The Custom Event Trigger type combined with RegEx matching is a very powerful way of blocking multiple Events at once.
If you want to create a comprehensive, universal, block-all Trigger Exception, all you need to do is set the Event name field to .* in the Exception Trigger. This means that whenever _any_ Event is registered by GTM, the Exception will block every single one of these, as they are all covered by the wildcard pattern in the regular expression.
Key takeaway here is this: the Exception Event must match the Trigger Event. For example, if you want to block a Click Trigger, you need to have a Click Trigger blocking it. Indeed, an easy way to block a single Trigger is to add the very same Trigger as the Exception!