DEV Community

Emily Grace
Emily Grace

Posted on

Consent Mode v2: The Load Order That Decides What Google Tags Do

TL;DR

  • Call the consent default command before the Google tag or GTM snippet loads.
  • Give an async banner time to respond with wait_for_update.
  • Send an update when the visitor accepts, and again when they withdraw.
  • Use region when UK, EU and US visitors need different defaults.

If GA4 and Google Ads disagree about your EEA traffic, or conversion modelling doesn't seem to start, check the order of your consent code first. Google's developer guide says the order is "vital" and that consent defaults won't work if the code runs out of order. Tags can then run with no consent state at all.

1. Defaults go first

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'ad_user_data': 'denied',
    'ad_personalization': 'denied',
    'analytics_storage': 'denied',
    'wait_for_update': 500
  });
</script>
<!-- Google tag or GTM snippet loads after this -->
Enter fullscreen mode Exit fullscreen mode

ad_user_data and ad_personalization are the two parameters added in v2. Since March 2024, Google has required consent from EEA users for advertisers who want to keep measurement, ad personalisation and remarketing features.

2. Update on accept and on withdrawal

gtag('consent', 'update', {
  'ad_storage': 'granted',
  'ad_user_data': 'granted',
  'ad_personalization': 'granted',
  'analytics_storage': 'granted'
});
Enter fullscreen mode Exit fullscreen mode

Withdrawal is the same call with 'denied'. Make sure your preference centre sends it too, or a withdrawal won't reach Google.

3. Basic or advanced

Basic mode blocks Google tags until the visitor consents. Advanced mode loads them in a denied state, and they send cookieless pings that Google uses to model conversions.

Why this matters to the business

The order decides whether tags set cookies before anyone has chosen, and whether you get modelled conversions for people who decline.

If you would rather not hand-write this, Seers handles Consent Mode v2 by setting all four signals from the banner choice, in basic or advanced mode. Seers is listed as a Gold partner in Google's CMP Partner Program.

Consent Mode only passes the choice to Google. Records, withdrawals and other vendors are part of wider consent management best practices.

Top comments (0)