Lessons in this module
Lesson 9 of 16
Consent Defaults Before Anything
① 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 Mode only works if the default state exists before anything else runs. If the container loads first, your earliest tags fire into a void: no consent state, nothing to obey. That is why GTM ships a special trigger, Consent Initialization, All Pages, guaranteed to run before every other trigger on the page, including Initialization and All Pages.
In this lesson you build the classic opening move: a Custom HTML tag that calls gtag('consent', 'default', ...) with every signal denied, firing on Consent Initialization. The timeline below narrates the page as it happens: default first, then the container, then tags. If a default ever lands late, it gets a red dot and an explanation of the gap.
Goal
Set an all-denied consent default in a Custom HTML tag on the Consent Initialization trigger, so it always runs before the container's tags.
Build it in GTM
Tag: Custom HTML - Consent Default
Go to Tags → New → Custom HTML and paste a default-consent call with every signal denied:
<script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('consent', 'default', { ad_storage: 'denied', analytics_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied' }); </script>On a real site your CMP template usually does this for you; writing it once by hand is how you learn what the template is actually doing.
Trigger: Consent Initialization, All Pages
Under Triggering, pick the built-in Consent Initialization, All Pages trigger (or create one: Triggers → New → Consent Initialization). GTM guarantees it runs before every other trigger, that guarantee is the whole point.Save and read the timeline
Name the tagCustom HTML - Consent Defaultand Save. Then watch the timeline on the live page: consent default (all denied) should sit above GTM container loaded, green dots all the way down.
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
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