Google Tag Manager
Cookie Consent Setup
Set up GTM cookie consent with Consent Mode V2 in under 5 minutes. Control exactly which tags fire based on user consent. About 28 KB gzipped, async loading, $99 one-time.
Set up in this order
Import the template, add the banner, stop existing tags that were already on the site, then preview.
1. Import the template
This sets consent to denied before any other tag runs.
- 1.In Google Tag Manager, click Templates in the left menu.
- 2.In the Tag Templates box, click New. A blank editor opens.
- 3.Click the three dots at the top right, next to Save. Click Import and pick cookie-banner-consent-mode.tpl from your Downloads folder.
- 4.The name changes to Cookie Banner Generator — Consent Mode v2 and you see Template created. If Save is blue, click it. Close the editor with the X at the top left.
- 5.Click Tags in the left menu, then New. Name it Cookie Banner Generator — Consent Mode.
- 6.Click Tag Configuration and choose Cookie Banner Generator — Consent Mode v2. Leave every field as it is. An empty table means everything starts as denied.
- 7.At the bottom of the Tag Configuration box, click Advanced Settings, then Tag firing priority. Type 1000.
- 8.Click Triggering and choose Consent Initialization - All Pages.
- 9.Click Save.
If you see a red error after importing, stop and email support@cookie-banner.ca with a screenshot.
2. Add the banner
Grab your real banner and paste it into the tag.
- 1.Click Grab your banner. On the dashboard, click Copy snippet.
- 2.Click Tags in the left menu, then New.
- 3.Name the tag Cookie Banner.
- 4.Click Tag Configuration and choose Custom HTML. Paste the snippet.
- 5.At the bottom of the Tag Configuration box, click Advanced Settings, then Tag firing priority. Type 50.
- 6.Click Triggering and choose Consent Initialization - All Pages.
- 7.Click Save.
Only if you can edit the site, and you did not paste the banner into the GTM tag above
Paste the copied snippet into the head, above the Google Tag Manager snippet. The example still says YOUR_BANNER_ID. Yours will already have the real ID. You still need the template from step 1.
1<script src="https://www.cookie-banner.ca/api/v1/banner.js?id=YOUR_BANNER_ID" async></script>Next.js sites only
Use this when the site is a Next.js app. Load the banner with strategy="beforeInteractive". Keep the GTM snippet on afterInteractive.
1<Script2 src="https://www.cookie-banner.ca/api/v1/banner.js?id=YOUR_BANNER_ID"3 strategy="beforeInteractive"4/>4. Preview, then publish
Check the site before you publish the container.
- 1.In GTM, click Preview at the top right. Enter your site address and click Connect.
- 2.On the site, leave the banner sitting there. In Tag Assistant, open the Consent tab. Ad Storage, Analytics Storage, Ad User Data, and Ad Personalization should say Denied.
- 3.Click a GA4 or ads tag in the left list. It should say it has not fired, or that consent blocked it. Refresh the page. It should still be blocked.
- 4.On the banner, click Accept All. Those tags should now say Fired.
- 5.Refresh the page. The tags should fire again, and the banner should stay hidden.
- 6.Back in GTM, click Submit, name the version, and click Publish.
Why this is separate from the banner
The setup is above. GTM does not wait for a banner on its own, so the template has to set denied before the other tags run.
Consent Mode V2 Required
Since March 2024, Google requires Consent Mode V2 for Google Ads in the EU. Without it, your remarketing audiences stop growing and conversion modeling breaks.
Granular Tag Control
Fire analytics tags only when analytics consent is granted. Fire advertising tags only when ad consent is granted. No more all-or-nothing.
Works via Head or GTM
Best: paste the banner in your site head, then add our Consent Mode v2 template. No site access? Load the banner as Custom HTML on Consent Initialization instead.
Preserve Conversion Data
Consent Mode V2 enables Google behavioral modeling for users who deny consent. You keep directional conversion data without violating privacy laws.
GDPR + CCPA Compliant
Modes for Canada, the EU, and California. Pro can show a different mode to a country you pick. There is no Brazil mode. Not a Google-certified CMP.
About 28 KB gzipped, Async
About 28 KB gzipped. One async script tag, so it does not block HTML parsing. That is not a Core Web Vitals or ranking promise.
What the banner sends
Reference only. You do not paste this. The template and the banner already send it.
What is Consent Mode V2?
Consent Mode V2 is Google's framework for adjusting tag behavior based on user consent. It is required for Google Ads in the EU since March 2024:
- Automatically adjusts data collection based on consent state
- Enables behavioral modeling for consented data gaps
- Required for Google Ads conversion tracking in the EU
- Supports granular consent categories (ads, analytics, functionality)
Required Consent Types
Consent Mode V2 requires these consent types. Our banner maps cookie categories to each one automatically:
- ad_storage: Controls advertising cookies (Google Ads, remarketing)
- ad_user_data: Controls sending user data for advertising
- ad_personalization: Controls personalized advertising
- analytics_storage: Controls analytics cookies (GA4)
- functionality_storage: Controls functional cookies
What Our Banner Does Automatically (You Do Not Write This)
This is the consent flow our script handles for you. Shown here so you understand what happens under the hood.
1// 1. On page load, our script sets default consent (denied)2gtag('consent', 'default', {3 'ad_storage': 'denied',4 'ad_user_data': 'denied',5 'ad_personalization': 'denied',6 'analytics_storage': 'denied',7 'functionality_storage': 'denied',8 'security_storage': 'granted'9});10 11// 2. When user clicks "Accept All" or grants specific categories:12gtag('consent', 'update', {13 'ad_storage': 'granted',14 'ad_user_data': 'granted',15 'ad_personalization': 'granted',16 'analytics_storage': 'granted',17 'functionality_storage': 'granted'18});19 20// 3. Pushes a consent event to the dataLayer for non-Google tags:21window.dataLayer.push({22 'event': 'cookie_consent_update',23 'analytics_storage': 'granted',24 'ad_storage': 'granted',25 'ad_user_data': 'granted',26 'ad_personalization': 'granted',27 'consent_analytics': true,28 'consent_marketing': true,29 'consent_preferences': true30});You do not need to write any of this code. Our cookie banner script handles all consent default/update calls and dataLayer pushes automatically. This is shown for transparency so you can verify the implementation in GTM Preview mode.
Frequently Asked Questions
Common questions about Google Tag Manager cookie consent and Consent Mode V2
What is Google Tag Manager Consent Mode V2 and why does it matter?
Consent Mode V2 is Google's updated framework for handling user consent signals in GA4, Google Ads, and other Google services. Since March 2024, Google requires Consent Mode V2 for any site running Google Ads in the EU. Without it, your conversion data is incomplete and your remarketing audiences stop growing. Our cookie banner sends the correct consent signals to GTM automatically.
How do I set up cookie consent in Google Tag Manager?
Download the Consent Mode v2 template on this page and import it into Google Tag Manager. Fire it on Consent Initialization — All Pages with ad storage, analytics storage, ad user data, and ad personalization set to denied, and set its priority to 1000. Add the banner as a Custom HTML tag on the same trigger at priority 50. On every other tag, open Advanced Settings, then Consent Settings, and choose Require additional consent for tag to fire. Tick analytics storage for GA4. Tick ad storage, ad user data, and ad personalization for Google Ads. Tick ad storage for Meta, LinkedIn, and the other ad pixels. Leave the template tag and the banner tag without that requirement.
Does this work with GA4, Google Ads, and Facebook Pixel in GTM?
Yes. Leave the Consent Mode template and the banner tag alone. On every other tag, open Advanced Settings, then Consent Settings, and choose Require additional consent for tag to fire. Tick analytics storage for GA4. Tick ad storage, ad user data, and ad personalization for Google Ads. Tick ad storage for Facebook, TikTok, and LinkedIn.
Can I deploy the cookie banner through GTM instead of adding a script tag?
Yes. Download the Consent Mode v2 template on this page, import it, and fire it on Consent Initialization — All Pages with defaults denied and firing priority 1000. Add the banner as a Custom HTML tag on the same trigger at a lower priority. Prefer adding the script to the site head when you can.
What happens to my Google Ads data if users deny consent?
With Consent Mode V2, Google uses behavioral modeling to estimate conversions from users who denied consent. You still get directional conversion data without violating privacy regulations. Without Consent Mode V2, you lose that data entirely. Our banner ensures the correct consent signals are always sent to Google.
How much does GTM cookie consent setup cost?
Our cookie banner is $99 one-time for the Pro plan. There are no monthly fees, no per-pageview charges, and no usage limits. The free plan lets you build and test your banner. The Pro plan includes unlimited pageviews, custom branding, Consent Mode V2 support, and priority support.
Ready to Set Up GTM Cookie Consent?
Build your cookie banner in the visual builder, deploy via GTM or a script tag, and your site has full Consent Mode V2 compliance. About 28 KB gzipped, async loading, works with every GTM setup.