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 https://www.uniconsent.com/docs/tutorials/gtm-integration.
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="https://business.safety.google/privacy/">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:
<script>
(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);
})();
</script>
or use the short tag:
<script src="https://cmp.uniconsent.com/v2/stubgcm.min.js"></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:
<script>
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('consent', 'default', {
functionality_storage: 'granted',
security_storage: 'granted'
})
</script>
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:
<noscript>
element right after opening the <body>
tag.Then follow the instructions at https://www.uniconsent.com/docs/tutorials/gtm-integration to setup UniConsent CMP via Google Tag Manager.
Google consent type | UniConsent Simple Mode consent type | Purpose |
---|---|---|
ad_storage | Targeting and Advertising | To enable advertisement cookies. |
analytics_storage | Performance | To enable analytics cookies. |
functionality_storage | Functionality | To enable functional cookies for website functionality and settings. |
personalization_storage | Functionality | To enable functional cookies for user personalization. |
security_storage | Strictly Necessary | To enable necessary cookies for website security and protection, user UI preferences, etc. Such cookies do not require consent. |
ad_user_data | Targeting and Advertising | To enable advertisement cookies to set consent for sending personal data to Google core platform service. |
ad_personalization | Targeting and Advertising | To enable advertisement cookies to use data for ad personalization such as remarketing. |
Purpose | Description | Google tag behavior when Purpose is denied |
---|---|---|
Store and/or access information on a device | ad_storage = denied | ad_storage = denied ad_user_data = denied |
Create a personalised ads profile | ad_personalization = denied | ad_personalization = denied |
Select personalized ads | ad_personalization = denied | ad_personalization = denied |
Measure ad performance | ad_user_data = denied | Disables the Google signals feature in Google Analytics (for web tags only). |
Apply market research to generate audience insights | Disables the Google signals feature in Google Analytics (for web tags only). | |
Develop and improve products | Disables the Google signals feature in Google Analytics (for web tags only). |
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 working
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.
Contact us: support@uniconsent.com