Lesson 5 of 15
Trigger Exceptions
① Connect your GTM container
Paste your container ID to load it into this page. It only ever runs here.
Advanced: use a specific environment
Sometimes a tag should fire almost everywhere, except a few pages, a conversion pixel that mustn't double-count on the checkout page, say. Rather than list every allowed page, you add a normal firing trigger and then a blocking (exception) trigger for the pages to skip.
Here you'll fire a tag on every navigation except /checkout. Exceptions always win: if a blocking trigger matches, the tag stays put.
Goal
Fire a tag on every page except one, using a blocking (exception) trigger.
Build it in GTM
Make the variable that reads the path
This sandbox stores the simulated path in a
?path=query parameter, so you'll build a small URL variable to read it. (On a real multi-page site the path is genuinely in the URL, so you'd skip this and use the built-inPage Pathvariable, enabled under Variables → Configure.)- Go to Variables in the left sidebar, then under User-Defined Variables click New.
- Click the variable-type box and choose URL.
- Set Component Type to Query so GTM returns one query parameter's value rather than the whole URL.
- In the Query Key field, type
path, the name of the parameter (the part before=), not its value. - Name it
URL - path paramat the top, then Save.
It now returns
/checkoutwhen the URL is?path=/checkout, ready for your exception trigger below.Create the firing trigger (fire everywhere)
This is the trigger that wants the tag to fire on every navigation.
- Go to Triggers in the left sidebar and click New.
- Click the trigger-type box and choose History Change. (Navigation here is
pushStatewith no reload; a real multi-page site would use a Page View trigger instead.) - Set it to All History Changes, with no conditions, so it matches every navigation.
- Name it
History - alland Save.
Create the exception trigger (the page to skip)
This trigger marks the one page where the tag must not fire. Make it a History Change too, so it is evaluated on the same event as the firing trigger.
- Go to Triggers → New again and choose History Change.
- Set it to Some History Changes so a condition appears.
- Add the condition
URL - path paramequals/checkout. - Name it
History - checkoutand Save.
Build the tag and wire both triggers
- Go to Tags → New and choose Custom HTML.
- Paste
<script></script>(it fires but does nothing, just so you can watch it in Tag Assistant) and name itCustom HTML - Test. - Under Triggering, add
History - allas the firing trigger. - Then click Add Exception, choose
History - checkout, and Save.
Exceptions always win: on
/checkoutthe blocking trigger matches and the tag stays put; everywhere else it fires.
Debug in Tag Assistant
Copy this lesson's live URL and paste it into GTM Preview, that is the page Tag Assistant connects to. It has the clickable elements, so this page stays clean for reading.
- In your GTM, click Preview.
- Paste the live URL above and click Connect.
- Interact with the live page and watch your tag fire in Tag Assistant.
What you should expect to see
History event. On /home and /blog your tag is under Tags Fired; on /checkout it moves to Tags Not Fired, with your exception listed under Blocking Triggers.Verify your container
Built it? Export your container, Admin → Export Container, choose your workspace, then drop the JSON here to check it against this lesson.
Drop your container .json here
or browse · checked in your browser, nothing is uploaded