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

Lesson 10 of 16

Wire The Banner

① Connect your GTM container

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

Advanced: use a specific environment

A consent banner's buttons are not magic. Each one does exactly two things: it calls gtag('consent', 'update', ...) so Consent Mode knows the visitor's choice, and it pushes a dataLayer event, here consent_update, so GTM can react to the choice. The first half gates tags; the second half lets you fire them the moment consent arrives.

The banner below is already wired that way (open the dataLayer log and press its buttons to see both pushes). Your job is the GTM side: a Custom Event trigger listening for consent_update, and a tag that fires on it. On a real site this is how you send the events you were holding back, the visit is not lost just because consent arrived late.

Goal

Build a Custom Event trigger on consent_update and fire a tag the moment the banner reports a choice.

Build it in GTM

  1. Know what the banner pushes

    Every button pushes { event: "consent_update", consent: {...}, granted_signals: [...] } right after its gtag('consent', 'update', ...) call. The event name is the hook; the payload tells you what was granted.
  2. Trigger: Custom Event - Consent Update

    Go to Triggers → New → Custom Event and set the event name to consent_update, exactly as pushed, lowercase with the underscore. Save it as Custom Event - Consent Update.
  3. Tag: fire on the choice

    Create a GA4 Event tag (event name consent_update) or the Custom HTML - Test stand-in with <script></script>, and set Custom Event - Consent Update as its firing trigger.

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

Press Accept all on the live page. Tag Assistant shows a consent_update message in the left rail with your tag under Tags Fired, and the Consent tab flips the granted signals from denied to granted at that same moment.

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?