Don't have one? Create one ↗
← All courses
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

  1. 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.

  2. 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.
  3. Save and read the timeline

    Name the tag Custom HTML - Consent Default and 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.

  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

In Tag Assistant's left rail the first message is Consent Initialization, and your Custom HTML tag fires on it before Initialization and Container Loaded. The Consent tab shows every signal's on-page default as denied.

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?