Don't have one? Create one ↗
← All courses
Lessons in this module

Lesson 13 of 16

Exception Triggers On Consent State

① Connect your GTM container

Paste your container ID to load it into this page. It only ever runs here.

Advanced: use a specific environment

Consent Settings are not the only way to hold a tag. Sometimes you want plain trigger logic: suppress this analytics tag while consent is denied, using the same exception (blocking) trigger mechanics you use everywhere else in GTM. The ingredient is a readable consent state: this page mirrors every banner choice into the dataLayer as { event: "consent_state", consent_state: "denied" }, so a Data Layer Variable can read it and a trigger can block on it.

Blocking alone loses data, though: the page view that happened before consent never fires. So you pair the exception with a recovery trigger: when the banner pushes consent_update with a grant, a second trigger refires the page view. The visit is counted late instead of not at all.

Goal

Block an analytics tag with a consent-state exception trigger, then recover the missed page view with a trigger on consent_update.

Build it in GTM

  1. Variable: DLV - consent_state

    Variables → New → Data Layer Variable, variable name consent_state. It reads "granted" or "denied" from the page's pushes.
  2. Blocking trigger: Consent Denied

    Triggers → New → Custom Event, event name page_view_sim, firing on Some Custom Events where DLV - consent_state equals denied. This is the condition you'll block on.
  3. Analytics tag with the exception

    Make a GA4 Event tag (or Custom HTML - Test) firing on a Custom Event trigger for page_view_sim. Then under Triggering → Add Exception, attach Consent Denied. Exceptions always win: while denied, the tag stays silent.
  4. Recovery trigger: Custom Event - Consent Update

    Add a Custom Event trigger on consent_update and fire the same analytics tag (or a dedicated page-view tag) on it. When consent arrives, the tag refires and the visit is not lost.

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

While rejected, simulate a page view: Tag Assistant shows your tag under Tags Not Fired with the exception as the reason. Accept the banner: the consent_update event fires the recovery trigger and the tag finally runs.

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 16 lessons complete
Was this lesson helpful?