cmpGoogle Consent Mode v2Google Tag Managercookie consent

How to Set Up Google Consent Mode v2 in Google Tag Manager

Marcin
9 July 2026
12 min read
How to Set Up Google Consent Mode v2 in Google Tag Manager

Setting up Google Consent Mode v2 in Google Tag Manager (GTM) depends on three things: the consent default must be set before any other tag runs, every tag must know which consent it needs, and you must test what happens after Reject, not only after Accept. This guide walks through the setup inside GTM itself: container settings, the Consent Initialization trigger, built-in and additional consent checks, non-Google tags and testing in Preview mode.

Last checked: 5 November 2026. This is practical implementation guidance, not legal advice. For the legal background and the signals themselves, read the Google Consent Mode v2 guide.

What regulators expect (in short)

The Consent Mode v2 guide covers the sources in detail. For a GTM setup, these points matter most:

  • Consent before storage. In the EU, article 5(3) of the ePrivacy Directive requires consent before analytics or advertising cookies are set. In the UK, PECR regulation 6 sets the same rule; its new analytics exemption has strict conditions and never covers advertising.
  • Reject on the first layer. EU authorities in the EDPB Cookie Banner Taskforce treat a banner with Accept but no Reject on the same layer as an infringement, and a reject "link" hidden in text is not enough either.
  • Nothing fires before the choice. The ICO's checks of the top 1,000 UK websites and the CNIL's €150 million fine against SHEIN both centred on advertising cookies set before a choice or after a refusal.
  • Withdrawal as easy as consent. Visitors need a permanently available way to change their mind.
  • Google's own policy. Google requires consent signals from advertisers who use Google Ads, remarketing or conversion measurement for visitors in the EEA, the UK and Switzerland.

Consent Mode only passes the choice to Google. If the banner fails these rules, a granted signal is not valid consent.

How the pieces fit together in GTM

Consent Mode v2 uses four signals: ad_storage, analytics_storage, ad_user_data and ad_personalization. In GTM, three parts work with them:

PartJob in GTM
Consent defaultSets all four signals to denied before any tag fires
CMP (consent management platform)Shows the banner, stores the choice and sends consent update
Tag consent settingsDecide whether each tag may fire, and how, for the current consent state

There are two common ways to get the CMP into GTM.

A stub script in the page, plus a CMP tag in GTM. A small synchronous script sits in the <head> above the GTM snippet and sets the default state before the container loads. The main CMP script then loads through GTM. This is the most robust order, because the default exists even before GTM starts.

A CMP template from the Community Template Gallery. The template runs on the Consent Initialization trigger and sets the default through Tag Manager's consent APIs. It needs no code edits on the site, but everything depends on that one tag firing first.

How CookiePilot does it: the Google Tag Manager integration uses the stub method. You paste the CookiePilot stub in the <head> before the standard GTM snippet and add the CookiePilot script as a Custom HTML tag on the Consent Initialization – All Pages trigger. The first synchronous script sets all four signals to denied with wait_for_update: 500. A CookiePilot GTM template was submitted to the Community Template Gallery on 28 October 2026 and is still under review, so for now use the stub method described on the integration page.

  1. Add the default before GTM. Place the CMP stub (or your own default block) at the top of the <head>, above the GTM container snippet. With CookiePilot it is one line:

    <script src="https://cdn.cookiepilot.io/stub.js"></script>
    

    If you use another CMP or write the default yourself, it looks like this (do not add it on top of the CookiePilot stub, which already sets these values):

    <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',
        wait_for_update: 500
      });
    </script>
    

    wait_for_update gives the CMP 500 ms to apply a choice the visitor saved on an earlier visit before tags fire.

  2. Turn on the consent overview. In GTM go to Admin > Container Settings and, under Additional Settings, select Enable consent overview. A Consent Overview icon then appears on the Tags page. It lists every tag, groups tags that still lack consent settings, and lets you edit several tags at once with Edit Consent Settings.

  3. Fire the CMP tag on Consent Initialization. Every web container has a built-in Consent Initialization – All Pages trigger. It fires before all other triggers, including Initialization triggers. Use it only for tags that set or update consent, such as the CMP tag. With CookiePilot this is the Custom HTML tag that loads the CookiePilot script. Do not put GA4, Google Ads or any other measurement tag on this trigger.

  4. Check Google tags' built-in consent checks. Open a Google tag (Google tag for GA4, Google Ads conversion or remarketing, Floodlight, Conversion Linker) and go to Advanced Settings > Consent Settings. The Built-In Consent Checks list shows which signals the tag already respects. These tags adjust their behaviour to the consent state on their own, so in advanced mode you can usually leave Additional Consent Checks on No additional consent required.

  5. Require consent for non-Google tags. Tags such as Meta Pixel, Hotjar or the LinkedIn Insight Tag have no built-in checks. Open each one, go to Advanced Settings > Consent Settings, choose Require additional consent for tag to fire and click + Add required consent. The tag then fires only if all listed signals are granted. A typical mapping:

    TagRequired consent
    Meta Pixelad_storage, ad_user_data, ad_personalization
    LinkedIn Insight Tagad_storage, ad_user_data
    Hotjaranalytics_storage
    Custom HTML with a third-party scriptwhatever matches its purpose

    Check this mapping against the categories in your banner and privacy notice.

  6. Make sure tags can fire after the choice. GTM does not re-run a tag that was blocked earlier on the same page. If the Meta Pixel trigger is All Pages and the visitor accepts after the page has loaded, the pixel stays blocked until the next page view. Add a trigger on the CMP's consent event, too. CookiePilot pushes cookiepilot_consent_update to the dataLayer, so create a Custom Event trigger with that name and attach it to the tags that should start right after acceptance. The consent check still applies, so after Reject the tag remains blocked. In Preview, check that the tag fires only once per page.

  7. Preview, then publish. Test every path in the matrix below in Preview mode before you publish the container version.

Basic or advanced mode in GTM terms

The difference shows up in the tag settings, not in a single switch.

  • Advanced mode: Google tags fire on their normal triggers while consent is denied. Their built-in checks stop cookies and send cookieless pings that Google uses for modelling. Setup: built-in checks only, No additional consent required.
  • Basic mode: Google tags do not fire at all until consent is granted. Setup: on each Google tag, choose Require additional consent for tag to fire and add the relevant signals (for example analytics_storage for GA4, and ad_storage plus ad_user_data for Google Ads conversions), with the consent-event trigger from step 6 so they start after acceptance.

Advanced-mode pings carry the visitor's IP address and browser details, and EDPB guidance treats IP-based tracking as potentially covered by the consent rule. If you are unsure, start with basic mode and have advanced mode reviewed by a lawyer first. Non-Google tags always behave like basic mode: with Require additional consent they do not fire at all without consent.

Region-specific defaults

Consent Mode lets you set different defaults per region with the region parameter: country codes in ISO 3166-1 alpha-2, for example region: ['GB', 'FR'], or ISO 3166-2 subdivisions such as 'US-CA'. The most specific region wins when two defaults overlap. Some sites use this to keep denied for the EEA and the UK while setting granted elsewhere.

Be careful: region detection relies on the visitor's IP address, VPNs and travellers make it imprecise, and other countries have their own rules. For a site aimed at EU and UK visitors, a single denied default for everyone is simpler and safer.

Test matrix: five paths in Preview mode

Open GTM Preview, which starts Tag Assistant, and enter your site's URL. Use a private window with no earlier cookies, and repeat each path from a fresh session.

To read the consent state, select a Consent event in the left-hand summary, or select a tag and open its Consent tab. The On-page Default column shows the default; On-page Update shows the state after the choice. The Tags tab shows which tags fired and which were blocked.

Note that the gcs parameter in network requests only reflects ad_storage and analytics_storage. Check the v2 signals ad_user_data and ad_personalization in the Consent tab and in the gcd parameter.

Pathanalytics_storageAd signals (ad_storage, ad_user_data, ad_personalization)What you should see
Before any choicedenieddeniedDefault comes before the first tag; no _ga, _gcl or _fbp cookies; Meta, LinkedIn and Hotjar tags Not fired; in advanced mode cookieless Google pings (gcs=G100)
RejectdenieddeniedSame as above after the click; in advanced mode only cookieless Google pings (gcs=G100)
Analytics onlygranteddeniedGA4 measures in full and Hotjar fires; Google Ads, Meta and LinkedIn stay blocked or cookieless
Accept allgrantedgrantedAll tags fire, including those on the consent-event trigger, without a reload
Withdrawback to deniedback to deniedAfter the visitor reopens the preferences and rejects, no new marketing requests or cookies are set. Consent Mode does not delete cookies set earlier (_ga, _fbp); the CMP has to remove them

Also check that the banner shows Reject next to Accept on the first layer. In CookiePilot the reject button can be shown as a "link"; avoid that style and keep both as equal buttons.

Common GTM mistakes

  • GA4 or Ads code hard-coded in the page. A gtag.js snippet or plugin outside GTM ignores the container's consent settings. Remove it or move it into GTM.
  • The CMP tag on All Pages instead of Consent Initialization. With a template-only setup, tags on Initialization or All Pages can then fire before the default exists; with a stub, the consent update can arrive too late for the first tags.
  • Measurement tags on the Consent Initialization trigger. That trigger is for consent tags only.
  • Custom HTML pixels with Not set. Not set means no additional checks, so a Meta Pixel in Custom HTML fires without consent.
  • No trigger after acceptance. Without the consent event trigger, tags that were blocked on page load wait for the next page view.
  • Only "Accept all" tested. Rejection, partial consent and withdrawal break more often.
  • Publishing without Preview. Every new tag in a campaign should go through the Consent Overview and Preview before release.

FAQ

No. A template is one option. A stub script in the <head> before GTM plus a CMP tag on the Consent Initialization trigger works too, and sets the default even before the container loads. CookiePilot currently uses this stub method.

It is a built-in GTM trigger, Consent Initialization – All Pages, that fires before all other triggers, including Initialization. It exists for tags that set or update consent, such as your CMP tag.

The tag fires only if every consent type you add is granted. Use it for non-Google tags such as Meta Pixel, Hotjar and LinkedIn, and for Google tags if you want basic mode.

Why does my tag not fire after the visitor clicks Accept?

The tag's trigger probably ran on page load while consent was still denied, and GTM does not re-run it. Add a trigger on your CMP's consent event, such as cookiepilot_consent_update.

Start Preview, select a Consent event or a tag, and open the Consent tab. Compare On-page Default with On-page Update, then check the Tags tab for tags that fired or were blocked.

Help with your GTM setup

Start with a tag inventory, put the default before GTM, set consent checks on every tag and run all five test paths in Preview. CookiePilot works with GTM, WordPress (WordPress integration), WooCommerce (WooCommerce integration) and PrestaShop (PrestaShop integration). The free Starter plan covers up to 10,000 pageviews a month, and paid plans have no pageview limit; see pricing. Need help? Use the chat in the CookiePilot dashboard. For technical details, see the documentation and the feature overview.

Written by

Marcin

The CookiePilot team writes about GDPR, cookies and Consent Mode v2 based on day-to-day work with consent banner rollouts.

Share this article: