OpenCookies

Guides

Google Consent Mode v2: how to set it up simply

By the OpenCookies team · published October 22, 2026 · updated October 22, 2026

The essentials in 3 lines

  1. Consent Mode v2 is how your site tells Google (Analytics, Ads) what the visitor has accepted or refused.
  2. It relies on four signals: ad_storage, analytics_storage, ad_user_data and ad_personalization. The last two are the ones added in version 2.
  3. The right order: “denied” by default before the Google tags, then an update as soon as the visitor chooses. OpenCookies does both and the test checks it.

The steps

  1. Understand the four signals
    • ad_storage: advertising cookies.
    • analytics_storage: audience measurement cookies.
    • ad_user_data: sending user data to Google for advertising purposes.
    • ad_personalization: personalized advertising and remarketing.

    Each is either granted or denied.

  2. Set the default value before any Google tag

    The default consent code must run before Google Tag Manager or gtag.js:

    <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' }); </script>
  3. Update at the moment of the choice

    When the visitor clicks, the banner sends the new state. Example after “Accept all”:

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

    A partial choice (measurement yes, advertising no) only changes the signals concerned. The choice must be stored and replayed on every page, otherwise the visitor is asked again.

  4. Let OpenCookies handle it

    With the OpenCookies line placed first in <head>, the default value is set before your tags and updated when the visitor chooses. Nothing to write by hand:

    <script src="https://opencookies.com/banner/oc.js" data-site="KEY"></script>

Check it with the OpenCookies test

The OpenCookies test shows, in a dedicated section of the report, the Consent Mode state at the three moments: default, after “Refuse” and after “Accept”. You should see the four signals “denied” before the choice and after refusal, then “granted” after acceptance.

On Google’s side, you can also use the Google Tag Manager preview (Tag Assistant), which shows the consent state at each event.

Test my site

Sources

This guide describes a technical approach, not legal advice.

Frequently asked questions

Does Consent Mode replace the banner?

No. Consent Mode does not collect the choice: it passes it to Google. You still need a banner that collects the visitor’s choice.

Basic or advanced mode?

In basic mode, Google tags do not load before consent. In advanced mode, they load and send cookieless signals before the choice. Basic mode is the more cautious; get advice for your case.

← All guides · Cookie dictionary