Google Consent Mode Integration

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.

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.

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

<script>
  window.dataLayer = window.dataLayer || []
  function gtag() {
    dataLayer.push(arguments)
  }
  gtag('consent', 'default', {
    ad_storage: 'denied',
    functionality_storage: 'denied',
    personalization_storage: 'denied',
    analytics_storage: 'denied',
    ad_user_data: 'denied',
    ad_personalization: 'denied',
    security_storage: 'denied',
  })
</script>

The above codes delay all the Google tag cookies until the user grants consent.

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

<script>
  window.dataLayer = window.dataLayer || []
  function gtag() {
    dataLayer.push(arguments)
  }
  gtag('consent', 'default', {
    functionality_storage: 'granted',
    security_storage: 'granted'
  })
</script>

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"
    }
}