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
Variable: DLV - consent_state
Variables → New → Data Layer Variable, variable nameconsent_state. It reads "granted" or "denied" from the page's pushes.Blocking trigger: Consent Denied
Triggers → New → Custom Event, event namepage_view_sim, firing on Some Custom Events whereDLV - consent_stateequalsdenied. This is the condition you'll block on.Analytics tag with the exception
Make a GA4 Event tag (orCustom HTML - Test) firing on a Custom Event trigger forpage_view_sim. Then under Triggering → Add Exception, attachConsent Denied. Exceptions always win: while denied, the tag stays silent.Recovery trigger: Custom Event - Consent Update
Add a Custom Event trigger onconsent_updateand 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.
- 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
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