Guides

How to set up a cookie banner with Google Tag Manager

Tarek RimanUpdated 2 min read

Short answer

To run a cookie banner through Google Tag Manager, add the banner tag with the Consent Initialization - All Pages trigger so it runs before everything else. Turn on consent overview in the container, give each non-Google tag the consent types it needs, and test in Preview mode that tags wait until the visitor agrees.

Key takeaways

  • Use the Consent Initialization - All Pages trigger for the banner tag.
  • Google tags read Consent Mode on their own; other tags need additional consent checks.
  • Do not fire marketing tags on plain All Pages triggers without a consent check.
  • Preview mode shows the consent state at each event.

Google Tag Manager is the easiest place to manage a consent banner if most of your tags already live there. The key is order: the banner must decide consent before any other tag runs.

Why the trigger matters

GTM has a special trigger called Consent Initialization – All Pages. It fires before every other trigger, including Initialization and All Pages. Putting your banner there means Consent Mode defaults are set before Google Analytics or Google Ads can send anything.

Step by step

  1. Turn on consent overview. In the container, open Admin, Container Settings, and enable Consent Overview.
  2. Create the banner tag. Add a Custom HTML tag with your North Consent script line.
  3. Use Consent Initialization – All Pages. Set it as the only trigger on the banner tag.
  4. Add consent checks to non-Google tags. Require ad_storage or analytics_storage on Meta, TikTok, Hotjar and similar tags.
  5. Preview and publish. Confirm everything is denied first, then granted after Accept, and publish the container.

Google tags and other tags

Google tags, such as the Google tag for GA4 and Google Ads conversion tags, read Consent Mode automatically. They adjust their behaviour based on ad_storage, analytics_storage, ad_user_data and ad_personalization. You do not need extra triggers for them.

Other tags, such as the Meta Pixel, TikTok or a Hotjar snippet in a Custom HTML tag, do not understand Consent Mode. For those, open the tag, go to Advanced Settings, Consent Settings and choose Require additional consent for tag to fire. Add ad_storage for advertising tags or analytics_storage for analytics tools. GTM will hold the tag until that consent is granted, then fire it.

Reacting to a choice mid-visit

If a visitor accepts after the page has loaded, tags with additional consent checks fire automatically once consent changes. North Consent also pushes an nc_consent_update event to the dataLayer, which you can use as a custom event trigger for anything that needs it.

Testing in Preview mode

Click Preview, open your site and watch the left side of Tag Assistant. Select the Consent Initialization event and open the Consent tab: all values should be denied. Tags that need consent should show as not fired. Accept on the banner, then check the next event: the values should change to granted and the held tags should fire.

Common mistakes

  • Adding the banner on All Pages instead of Consent Initialization.
  • Leaving a hard-coded gtag snippet in the theme as well as in GTM, so one copy ignores consent.
  • Marketing tags in Custom HTML with no consent check.

Not using GTM? See how to add the banner directly to WordPress.

Frequently asked questions

Can I put the banner in GTM and in the theme?

Pick one. Loading it twice can create two banners or conflicting consent states.

Does the banner slow down my GTM container?

It adds one small script that runs first. Tags that wait for consent do not load until needed.

Do I still need Consent Mode if I use GTM?

Yes. GTM is how the tags are delivered; Consent Mode is how Google tags learn the choice. The banner sets Consent Mode for you.

About the author

Tarek Riman

Founder of North Consent and Riman Agency in Montreal. He builds and optimizes websites for brands in Canada and the US.

Keep reading

Guides

How to audit the cookies on your website

A practical cookie audit: find every cookie and tracker on your site, sort them into categories, check what fires before consent, and keep the list current.

2 min read