How to install Google Consent Mode v2 with GTM?

Instructions about how to install Google Consent Mode v2 with Google Tag Manager?

Written by NelsonLast update 14 days ago

Google allows the use of its own consent mode by including APIs to control tag cookie storage based on user consent choices without disabling services provided by Google, such as Google Tag, Google Analytics, Google Ads, Floodlight, and Conversion Linker. Google Consent Mode v2 could be implemented using either the global site tag (gtag.js) or Google Tag Manager (GTM).

This video will help you to implement Google Consent Mode easily with CookieScript:

CookieScript has full integration with Google Consent Mode v2

  • Tag Manager Community Template available

  • Integrated with consent update calls

  • Integrated with consent default calls

  • Supported consent types:

    • ad_storage

    • analytics_storage

    • ad_user_data

    • ad_personalization

    • functionality_storage

    • personalization_storage 

    • security_storage

The easiest way to implement Google Consent Mode v2 on your website is by using a CookieScript Google Tag Manager (GTM) tag template. This is the recommended Google Consent Mode v2 installation method. It comes with all the necessary default consent state settings and code, so you don't need to worry about writing a single line of code. 

First, create your GTM account and a website container in GTM, and install the GTM container code to your website, where you could add your tags. Read the guide on how to create a GTM account and install the GTM container.

Second, install CookieScript using a GTM Tag template. To install CookieScript using a GTM Tag template, follow the steps below: 

Step 1: Go to Tags and click New

Step 2: Fill in the name and click on the Tag Configuration area:

Step 3: Click on the link to show Community Template Gallery and search for CookieScript:

Step 4: Click Add to Workspace and confirm your choice.

Step 5: Configure the banner according to your needs: fill in your Cookie Banner script URL (can be found in the banner settings > Installation tab) and choose the default consent state (which is applied before the user makes any selection):

Step 6: As a firing trigger choose Consent Initialization - All Pages. It's important to have this specific trigger since it is fired before any other tags and ensures proper work of the Tag.

All done, just publish the changes and the Google Consent Mode v2 will be implemented into your website or app.

Enable Google Consent Mode v2 in the cookie banner settings

Google Consent Mode v2 should be enabled in your cookie banner settings too. Go to your banner settings > Behavior tab > Frameworks section > Enable Google Consent Mode V2

You can optionally change a category that allows Ads Storage, Analytics Storage, Functionality Storage, Personalization Storage, and Security Storage in Google Consent mode. 

How do CookieScript categories map to Google Consent types?

Unlike other Consent Management Platforms, CookieScript allows you to map Google Consent types with categories used in your banner. This can be done in your banner settings > Behavior tab > Google Consent mode option.

Google consent type

CookieScript mapped category (can be adjusted in banner settings)

ad_storage (required)


analytics_storage (required)


functionality_storage (optional)


personalization_storage (optional)


security_storage (optional)


ad_personalization (required)


ad_user_data (required)


Checklist for the correct implementation of Google Ads and Google Consent Mode v2

  1. Google Consent Mode is enabled in settings.
    See the guide about how to enable Google Consent Mode v2.

  2. CookieScript is installed in GTM using the latest template from gallery.
    See the guide about how to update the GTM template.

  3. CookieScript trigger is set to Consent Initialization (AND no other tags in that trigger)

  4. GA trigger is set to Initialization
    The right GA trigger should look like this:

    The common mistake is the wrong GA trigger selected like in this example:

  5. Clear browser Cache

  6. Use preview mode to see how it works. Link to debugger info.

Note: If you want to check that CookieScript is implemented correctly, go to your account > Settings, where at the top of the page you will find information about your banner status. Wait until the scan finishes, then the banner status will be updated:

Also read the article about how to check if Google Consent Mode v2 is activated.

Other Google Consent Mode v2 installation methods:

How to implement Google Consent Mode v2 manually (not recommended)?

How to implement Google Consent Mode v2 using a Wordpress plugin?

Note: To implement Google Consent Mode v2, use only one method.

Note: If you implemented Google Consent Mode v2 using a GTM tag template, the Google Ads script should also be implemented using a GTM tag template. Also, make sure that you use a trigger, which sets the Google Ads script after the trigger Consent initialization. If you implemented consent mode v2 using a GTM tag template, and implemented the Google Ads script manually, your Ads script will not work.

If you implemented consent mode v2 manually, implement the Google Ads script manually as well. Just make sure that your cookie banner script loads first, and only then- the Google Ads script.

For more information, read the following documentation from Google:

Google documentation for web:

Google documentation for app:

Did this answer your question?