Google Consent Mode Integration with UniConsent CMP

Before you get started, you need to sign up for UniConsent and obtain a license ID for your website or app.

Google Consent Mode is an API that allows you to send anonymous event data to Google Ads, Campaign Manager, Display & Video 360, Search Ads 360, and Google Analytics.

If you don't have consent mode v2 implemented, you won't have the option to remarket/personalize ads to these audiences in the future. To retain measurement for these audiences, you should implement consent mode V2 by the end of 2024 for EEA users.

UniConsent seamlessly integrates with Google Consent Mode. There is no need for any special configuration to enable this integration, as long as you have installed UniConsent CMP tags on your web pages either manually or via the Google Tag Manager. You can turn this off at your CMP dashboard if you don't use Consent Mode.

You can find instructions about how to install UniConsent via Google Tag Manager at

You can use the Google-recommended consent message if you only use Consent Mode but not the IAB TCF/IAB GPP API.

We use cookies to provide you with the best possible experience. They also allow us to analyze user behavior in order to constantly improve the website for you. <a href="">Privacy Policy</a>

Node: You must implement the following default consent status script to make Google Consent Mode V2 work if not using Google Tag Manager.

Place the following tag just before the UniConsent CMP tag and before your Google tags or any other advertising tags:

(function() {
    if(!window['gtag']) {
        window['dataLayer'] = window['dataLayer'] || [];
        window['gtag'] = function(){window['dataLayer'].push(arguments);}
    window['gtag']('set', 'developer_id.dZTcxZD', true);
    if(localStorage && localStorage.getItem('__unic_consent_mode') !== null) {
        var consentStatus = JSON.parse(localStorage.getItem('__unic_consent_mode'));
        window['gtag']('consent', 'default', consentStatus);
    } else {
        window['gtag']('consent', 'default', {
            ad_storage: 'denied',
            functionality_storage: 'denied',
            personalization_storage: 'denied',
            analytics_storage: 'denied',
            ad_user_data: 'denied',
            ad_personalization: 'denied',
            security_storage: 'granted',
    window['gtag']("set", "ads_data_redaction", true);
    window['gtag']("set", "url_passthrough", true);

or use the short tag:

<script src=""></script>

The above code delays all the Google tag cookies until the user grants consent, except for security_storage.

You can update the values of ads_data_redaction and url_passthrough based on your requirements.

If some of the options are not required by default in your country, you can change the value to be granted. For example:

  window.dataLayer = window.dataLayer || []
  function gtag() {
  gtag('consent', 'default', {
    functionality_storage: 'granted',
    security_storage: 'granted'

If Google Tag Manager is already set up on your website, ensure that you place the GTM script right after the Custom Consent Mode Script and before the UniConsent tag.

If Google Tag Manager isn't set up on your website, follow the steps below:

  1. Register/Establish a Google Tag Manager Account and create a container.
  2. Go to the Google Tag Manager Dashboard and select the Container ID from the top navigation panel.
  3. Insert the GTM script between the custom script and the UniConsent tag. Also, remember to add the <noscript> element right after opening the <body> tag.

Then follow the instructions at to setup UniConsent CMP via Google Tag Manager.

Google consent typeUniConsent Simple Mode consent typePurpose
ad_storageTargeting and AdvertisingTo enable advertisement cookies.
analytics_storagePerformanceTo enable analytics cookies.
functionality_storageFunctionalityTo enable functional cookies for website functionality and settings.
personalization_storageFunctionalityTo enable functional cookies for user personalization.
security_storageStrictly NecessaryTo enable necessary cookies for website security and protection, user UI preferences, etc. Such cookies do not require consent.
ad_user_dataTargeting and AdvertisingTo enable advertisement cookies to set consent for sending personal data to Google core platform service.
ad_personalizationTargeting and AdvertisingTo enable advertisement cookies to use data for ad personalization such as remarketing.
PurposeDescriptionGoogle tag behavior when Purpose is denied
Store and/or access information on a devicead_storage = deniedad_storage = denied ad_user_data = denied
Create a personalised ads profilead_personalization = deniedad_personalization = denied
Select personalized adsad_personalization = deniedad_personalization = denied
Measure ad performancead_user_data = deniedDisables the Google signals feature in Google Analytics (for web tags only).
Apply market research to generate audience insightsDisables the Google signals feature in Google Analytics (for web tags only).
Develop and improve productsDisables the Google signals feature in Google Analytics (for web tags only).

1. Use Google's Tag Assistant

Navigate to Consent on the left side and click it, then click the Consent tab on the right side. You should see something like the following:

How to confirm UniConsent CMP for Google Consent Mode is workingHow to confirm UniConsent CMP for Google Consent Mode is working

2. Use DataLayer API:

Enter window.dataLayer = window.dataLayer || []; into console of your browser, you should find a section consent, update.

    "0": "consent",
    "1": "update",
    "2": {
        "ad_storage": "granted",
        "ad_user_data": "granted",
        "analytics_storage": "granted",
        "functionality_storage": "granted",
        "personalization_storage": "granted",
        "ad_personalization": "granted",
        "security_storage": "granted"

You can use the following Javascript API to access the Google Consent Mode Data:

(function waitCMP() {
  var readyCMP
  if (!readyCMP && window['dataLayer']) {
    window['dataLayer'].forEach(function (event) {
      if (event['event'] === 'unic_data') {
        readyCMP = 1
  if (!readyCMP) {
    setTimeout(waitCMP, 100)

You can install UniConsent Consent Validator to verify Consent Mode data is passing on your webpages.

Still have questions?

Contact us: