Free tool

Google Consent Mode v2 generator

Consent Mode v2 tells Google tags what a visitor agreed to. Since March 2024 Google requires the two new signals — ad_user_data and ad_personalization — for measurement and remarketing with EEA traffic. Configure your defaults below and copy a snippet that works with gtag.js and Google Tag Manager.

Updated 1 October 2026

Setup

Where are defaults denied?

Default state before a choice

  • ad_storagemarketingdenied
  • ad_user_datamarketingdenied
  • ad_personalizationmarketingdenied
  • analytics_storageanalyticsdenied
  • functionality_storagefunctionaldenied
  • personalization_storagefunctionaldenied
  • security_storagenecessarygranted
ads_data_redaction
url_passthrough

1 · Defaults — first thing in <head>

html
<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',
    functionality_storage: 'denied',
    personalization_storage: 'denied',
    security_storage: 'granted',
    wait_for_update: 500
  });
  gtag('set', 'ads_data_redaction', true);
</script>
<!-- then your gtag.js snippet -->

2 · Update when the visitor chooses

js
// Call this from your banner when the visitor chooses:
function onConsent(choice) { // { analytics: true, marketing: false, functional: true }
  var g = function (b) { return b ? 'granted' : 'denied'; };
  gtag('consent', 'update', {
    ad_storage: g(choice.marketing),
    ad_user_data: g(choice.marketing),
    ad_personalization: g(choice.marketing),
    analytics_storage: g(choice.analytics),
    functionality_storage: g(choice.functional),
    personalization_storage: g(choice.functional)
  });
}

How Consent Mode v2 works

Consent Mode has two commands. The default command runs before any Google tag and says what's allowed when nobody has chosen yet — in the EEA that should be denied for everything except security. The update command runs when the visitor makes a choice and flips the relevant signals to granted.

With signals denied, Google tags don't read or write advertising and analytics cookies. In 'advanced' mode they still send cookieless pings that Google uses for conversion modelling; in 'basic' mode tags don't load at all until consent. PrivacyPill implements advanced mode by default and lets you hold back any other script entirely.

The seven consent types

Consent Mode v2 knows seven storage types. Map them to your banner categories like this:

  • analytics_storage → Analytics
  • ad_storage, ad_user_data, ad_personalization → Marketing & advertising
  • functionality_storage, personalization_storage → Functional
  • security_storage → Strictly necessary (always granted)

Common mistakes

We see these in scans every week:

  • Setting the default after GTM or gtag.js has already loaded — the first hits go out without consent state.
  • Only setting ad_storage and analytics_storage (Consent Mode v1). Without ad_user_data and ad_personalization, EEA ad measurement degrades.
  • Granting everything by default 'because the banner is shown anyway' — the default must reflect the state before a choice.
  • Forgetting to send an update on returning visits. The stored choice must be re-applied on every page load.

Skip the snippet: let PrivacyPill do it

The PrivacyPill script sets the default before anything else, re-applies stored choices on every page view, sends updates instantly and pushes a privacypill_consent event to the dataLayer for GTM triggers. It also detects a fail-safe default you've placed inline and won't set it twice.

Frequently asked questions

Try it on your own site

Design your banner, preview it live, and paste one line. Free for one domain.