Home › Tools › Analytics and Tracking Tools › Consent Mode v2 Generator
Free Analytics Tool

Consent Mode v2 Generator

Choose your default consent settings and where they apply. Get the consent default code for every page, plus the update code your cookie banner runs when a visitor accepts or rejects.

Default Consent Settings

1. Consent Default Code

Paste into the <head> of every page, above your Google tag or Tag Manager snippet.


      
Copied!

2. Consent Update Code

Call these functions from your banner buttons, and again on later visits once you know the saved choice.


      
Copied!

What Is Google Consent Mode v2?

Consent mode tells Google tags what a visitor has agreed to. When a visitor says no to cookies, tags stop setting advertising and analytics cookies but can still send basic, cookieless signals. Google then uses those signals to model the conversions and visits you would otherwise lose.

Version 2 added two consent types, ad_user_data and ad_personalization. Google requires them for advertisers who want to keep audience and measurement features for visitors in the European Economic Area. The code this tool writes follows Google's consent mode setup guide for websites.

How to Use the Generator

  1. Choose where the defaults apply. Most sites deny by default in the EEA, UK and Switzerland and grant elsewhere.
  2. Set each consent type. Advertising and analytics start as denied. Security storage normally stays granted.
  3. Keep a short wait. wait_for_update gives your cookie banner time to load a saved choice before tags fire. 500 ms suits most banners.
  4. Paste the default code into the head of every page, above the Google tag or Tag Manager container.
  5. Connect the update code to your banner's Accept and Reject buttons, and run it again on each page view once the choice is saved.

The Seven Consent Types

Consent typeWhat it controls
ad_storageCookies and storage used for advertising
analytics_storageCookies used for analytics, such as visit length
ad_user_dataSending user data to Google for advertising (new in v2)
ad_personalizationPersonalized advertising such as remarketing (new in v2)
functionality_storageStorage that makes the site work, such as language settings
personalization_storageStorage for personal features such as recommendations
security_storageStorage for security, logins and fraud prevention

Basic or Advanced Consent Mode?

In basic mode, Google tags do not load at all until the visitor accepts, so nothing is sent before consent. In advanced mode, tags load straight away with consent denied and send cookieless pings, which gives Google more data to model with. The default code from this tool works for both. For basic mode, your consent platform also blocks the tags until the visitor accepts.

Learn More

Read consent mode v2 explained for website owners, see why first party data and privacy matter more each year, and consider server side tagging for more control. Ready to send events once consent is in place? Use the GA4 event code generator.

Frequently Asked Questions

1Where do I put the consent mode code?

Put the default code in the head of every page, above the Google tag or Google Tag Manager snippet. It must run before any config or event command so the defaults apply to the very first hit.

2Does this replace a cookie banner?

No. Consent mode only passes the visitor's choice to Google tags. You still need a cookie banner or consent management platform to ask for consent and call the update code.

3What does wait_for_update do?

It tells Google tags to wait a set number of milliseconds for an update command before sending data. This gives your banner time to load a choice the visitor made on an earlier visit.

4Is anything I enter uploaded?

No. The code is built in your browser and nothing you type is sent to a server.

Related Articles

More Free Analytics and Tracking Tools

See all analytics and tracking tools →  |  Browse every free tool →