Skip to content
LandexHub

Google Consent Mode v2, explained simply

· 5 min read

On this page
  1. Why it matters
  2. What Consent Mode does
  3. Basic and advanced mode
  4. Setting it up in code with gtag
  5. Setting it up in Google Tag Manager
  6. How to check that it works
  7. Common mistakes

You have Google Analytics or Google Ads on your website and a cookie banner, but are they actually talking to each other? This guide explains what Consent Mode v2 does, what the setup looks like in code and in Google Tag Manager, and how to check it yourself. It is for website owners and for the people who set up their banners.

Why it matters

Under EU rules, a website may store cookies that are not strictly necessary only after the visitor actively agrees. Analytics and advertising therefore have to follow what the visitor chose in the banner.

Consent Mode is how that choice reaches Google tags. Google requires it for advertising and measurement of visitors from the European Economic Area. When it is missing, or sends only the two older signals, Google Ads loses conversion data and cannot fully use remarketing or personalisation.

The banner finds out what the visitor agrees to, and Consent Mode expresses that state with four signals. Each one is either granted or denied.

Signal What it controls
ad_storage Cookies for advertising
analytics_storage Cookies for analytics, such as Google Analytics
ad_user_data Sending user data to Google for advertising
ad_personalization Personalised advertising and remarketing

Setting it up takes two steps:

  • default sets the initial state before any Google tag loads. For visitors from the EU, the default is denied for all four signals.
  • update changes the state when the visitor clicks in the banner. The banner must also call update on every following page where consent is already stored.

Basic and advanced mode

Consent Mode has two modes. They differ in what happens before consent.

Basic mode Advanced mode
Google tags load Only after consent Right away, with the default denied
Data without consent None Cookieless signals without identifiers
Modelling of missing data General model More precise model from your own signals

Basic mode is simpler and sends nothing to Google without consent. Advanced mode gives Google more to model conversions from, but some signals leave the browser even for visitors who declined.

Setting it up in code with gtag

If Google Analytics is added directly with the gtag.js snippet, the default state has to come before it. The code belongs in the page head, as high as possible:

page headHTML
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }

  // Default state before consent
  gtag('consent', 'default', {
    ad_storage: 'denied',
    ad_user_data: 'denied',
    ad_personalization: 'denied',
    analytics_storage: 'denied',
    wait_for_update: 500
  });
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

wait_for_update tells the tags how many milliseconds to wait for the banner to read stored consent.

When the visitor clicks Accept all, the banner calls update. If the visitor allows only analytics, the advertising signals stay denied:

JavaScript
// Consent to everything
gtag('consent', 'update', {
  ad_storage: 'granted',
  ad_user_data: 'granted',
  ad_personalization: 'granted',
  analytics_storage: 'granted'
});

// Consent to analytics only
gtag('consent', 'update', {
  analytics_storage: 'granted'
});

Setting it up in Google Tag Manager

In Tag Manager, the default state is set by the cookie banner’s tag. Most banners have their own template in the Community Template Gallery that handles both the default and the update.

  1. Add the banner tag

    Create a tag from your banner’s template and set the default to denied for all four signals.

  2. Use the right trigger

    The banner tag must fire on Consent Initialization - All Pages. This trigger runs before all other tags.

  3. Check the Google tags

    Google Analytics and Google Ads tags have built-in consent checks and follow the signals on their own. Do not add anything else to them.

  4. Take care of other tags

    Tags from other vendors (Meta Pixel, LinkedIn, chat widgets) do not read Consent Mode. In the consent settings of each one, require the matching signal, such as ad_storage, so that it does not fire without consent.

  5. Test and publish

    Go through the website in Preview mode and only then publish the version.

How to check that it works

Open the website in a private window and start Tag Manager Preview or Tag Assistant. The Consent tab shows two states:

  • On-page Default must show denied for all four signals, before the first Google tag.
  • On-page Update appears after you click in the banner and must match what you chose.

The other option is the Network panel in the browser’s developer tools. Google Analytics requests carry a gcs parameter with the consent state. How to read it is in the guide How to check that your cookie banner waits for consent.

After a few days, Google Ads shows a diagnostic for conversions that tells you whether the account receives consent signals.

Common mistakes

  • Default state after the Google tag. The first page view is then measured regardless of consent.
  • Only two signals. The banner sets ad_storage and analytics_storage, but ad_user_data and ad_personalization from version 2 are missing.
  • Update only on click. On the following pages, consent is not passed on again and measurement stops.
  • Default set to granted. Tags then store cookies before the visitor has chosen.
  • Other vendors’ tags without a consent check. Meta Pixel or LinkedIn fire even without consent, because they do not read Consent Mode.
  • Two banners or two defaults. Typically a banner plugin plus a manual snippet in the theme. The state then gets overwritten unpredictably.
Additional settings for advertising

When ad_storage is denied, you can ask Google to remove click identifiers from page URLs, or to pass them between pages in links instead of cookies:

JavaScript
gtag('set', 'ads_data_redaction', true);
gtag('set', 'url_passthrough', true);

Both settings go right after the default state and before gtag.js loads.

On WordPress, LandexHub Consent prints the default state at the top of <head>, before the Google tags it loads, and updates it on every page. The guide How to set up LandexHub Consent on WordPress walks through the setup.

Frequently asked questions

Does Consent Mode replace the cookie banner?
No. Consent Mode only passes the visitor's choice on to Google tags. The choice itself has to come from a cookie banner, which stores the consent and updates Consent Mode.
What is the difference between basic and advanced mode?
In basic mode, Google tags load only after consent. In advanced mode they load right away, but without consent they set no cookies and send only limited signals that Google uses to model missing data.
Is it enough to set only ad_storage and analytics_storage by default?
No. Version 2 added ad_user_data and ad_personalization. Without them, Google limits advertising features such as remarketing and conversion measurement for visitors from the EEA.

Similar guides