Free tool

Google Consent Mode v2 Code Generator (Default & Update)

Create the consent default snippet that must load before your Google tags, and the update call your cookie banner should fire.

Also include:
Default consent: in the <head>, before GTM
<!-- Place this above your Google Tag Manager or gtag.js code -->
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  // Visitors in the EEA, UK and Switzerland: denied until they accept
  gtag('consent', 'default', {
    ad_storage: 'denied',
    ad_user_data: 'denied',
    ad_personalization: 'denied',
    analytics_storage: 'denied',
    wait_for_update: 500,
    region: ['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'IS', 'LI', 'NO', 'GB', 'CH']
  });
  // Everyone else: granted by default
  gtag('consent', 'default', {
    ad_storage: 'granted',
    ad_user_data: 'granted',
    ad_personalization: 'granted',
    analytics_storage: 'granted'
  });
  gtag('set', 'ads_data_redaction', true);
</script>
Consent update: fire from your cookie banner
// Call this from your cookie banner when the visitor accepts
gtag('consent', 'update', {
  ad_storage: 'granted',
  ad_user_data: 'granted',
  ad_personalization: 'granted',
  analytics_storage: 'granted'
});

Using a certified CMP such as Cookiebot or CookieYes? Most of them set these defaults for you through their GTM template, so check before adding the code twice.

What Consent Mode v2 changes

Consent Mode v2 added two signals, ad_user_data and ad_personalization, next to ad_storage and analytics_storage. Google requires them for advertisers who use audience features and measurement for users in the EEA. Without them, remarketing lists and some conversion measurement for those users stop working.

Default first, then update

The default command must run before any Google tag, so tags know what they are allowed to do on the first hit. When the visitor makes a choice in the cookie banner, an update command changes the consent state. If your banner is a certified CMP, it usually handles both through its GTM template.

FAQ

Frequently asked questions

What is the difference between basic and advanced consent mode?

In basic mode, Google tags do not load until the visitor accepts. In advanced mode, tags load with consent denied and send cookieless pings, which Google uses for conversion modelling. This snippet works for advanced mode; for basic mode, block the tags until consent is granted.

Do I need Consent Mode if my visitors are not in Europe?

Google requires it for EEA users. Many sites set denied only for the EEA, UK and Switzerland and granted elsewhere, which is what the EEA option in this generator does. Check the privacy laws that apply to your business.

How do I check that Consent Mode works?

Use Tag Assistant or GTM preview and look at the Consent tab for each event. You should see the default state on page load and the updated state after accepting the banner.

Ready to fix your tracking and scale your ads?

Get a free audit of your tracking and ad account. Usually replies within 1–2 hours.