What is Google Consent Mode?

Google Consent mode allows you to convey your users' consent status regarding cookies or app identifiers to Google, enabling tags to adjust their behavior in accordance with users' preferences.

This feature seamlessly integrates with UniConsent Consent Management Platform (CMP). Consent mode receives and responds to your users' consent choices obtained through your cookie banner or widget. It dynamically modifies the behavior of Analytics, Ads, and third-party tags responsible for creating or accessing cookies.

In cases where visitors decline consent, tags don't store cookies; instead, they send signals to Google. If you are utilizing Google Analytics 4, Google compensates for data collection gaps by employing conversion modeling and behavioral modeling techniques.

  • Google Analytics
  • Google Ads
  • Floodlight
  • Conversion Linker

You can find more about Google Consent mode at https://support.google.com/analytics/answer/9976101?hl=en

UniConsent CMP has the native support for Google Consent Mode API and it is integrated automatically.

1. Use Google Tag Assistant

Find Consent at the left side and click, then click Consent tab at 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
        console.log(event['CONSENT_MODE'])
      }
    })
  }
  if (!readyCMP) {
    setTimeout(waitCMP, 100)
  }
})()

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