Don't have one? Create one ↗
← All courses

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

  1. 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-in Page Path variable, enabled under Variables → Configure.)

    1. Go to Variables in the left sidebar, then under User-Defined Variables click New.
    2. Click the variable-type box and choose URL.
    3. Set Component Type to Query so GTM returns one query parameter's value rather than the whole URL.
    4. In the Query Key field, type path, the name of the parameter (the part before =), not its value.
    5. Name it URL - path param at the top, then Save.

    It now returns /checkout when the URL is ?path=/checkout, ready for your exception trigger below.

  2. Create the firing trigger (fire everywhere)

    This is the trigger that wants the tag to fire on every navigation.

    1. Go to Triggers in the left sidebar and click New.
    2. Click the trigger-type box and choose History Change. (Navigation here is pushState with no reload; a real multi-page site would use a Page View trigger instead.)
    3. Set it to All History Changes, with no conditions, so it matches every navigation.
    4. Name it History - all and Save.
  3. 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.

    1. Go to Triggers → New again and choose History Change.
    2. Set it to Some History Changes so a condition appears.
    3. Add the condition URL - path param equals /checkout.
    4. Name it History - checkout and Save.
  4. Build the tag and wire both triggers

    1. Go to Tags → New and choose Custom HTML.
    2. Paste <script></script> (it fires but does nothing, just so you can watch it in Tag Assistant) and name it Custom HTML - Test.
    3. Under Triggering, add History - all as the firing trigger.
    4. Then click Add Exception, choose History - checkout, and Save.

    Exceptions always win: on /checkout the 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.

  1. In your GTM, click Preview.
  2. Paste the live URL above and click Connect.
  3. Interact with the live page and watch your tag fire in Tag Assistant.

What you should expect to see

Each navigation adds a 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

0 of 15 lessons complete