Google Consent Mode API is now supported by CMP Cookie First.
Google Consent Mode allows for better conversion and tracking data while still being compliant to the GDPR. Cookie First is among the few CMPs that have implemented this feature.
Why is this Google Consent Mode important for website owners?
The main reason is this gives you a lot more insight in traffic and conversions while still being compliant to the users consents. You can have GTM, Google analytics or Google Ads working on your website without the use of analytics and marketing cookies. For instance with Ads usually no ads would show on your website because the advertising scripts would simply not fire if someone didn't consent to Advertising cookies. The same goes for analytics. But with this major change by Google you have a lot more insight and data while still respecting the users consent preference!
The implementation in this article works with the following Google services:
- Google Ads (Google Ads Conversion Tracking and Remarketing)
- Floodlight
- Google Analytics
- Conversion Linker
More information about this can be found here: https://support.google.com/analytics/answer/9976101
The Consent Mode changes the way Google tags behave according to the consent status of the website visitor. We have made this integration very easy for users of Cookie First.
Basically there are two commands that are being used with the gtag ('consent') API.
1. gtag ('consent', 'default') and
2. gtag ('consent', 'update')
These two will control the two new tag settings that can be send.
Tag | Value | Default | Description |
---|---|---|---|
ad_storage | 'denied' | 'granted' | 'denied' | Whether or not to use cookies related to advertising |
analytics_storage | 'denied' | 'granted' | 'denied' | Whether or not to use cookies related to analytics |
Enable Google Consent Mode in your website
Add the code below to your website before you load Google Tag Manager or gtag.js . The code below has some variables you can change but shouldn't actually as this is the most GDPR friendly way.
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied',
'wait_for_update': 1500 //milliseconds
});
gtag('set', 'ads_data_redaction', true);
</script>
Updating the consent
When a website visitor agrees to accepting performance or marketing cookies Cookie First executes the update command: gtag ('consent', 'update') where ad_storage and respectively analytics_storage are granted.
Redacting Advertising data
If ad_storage is denied Google tags will not set any new cookies for advertising purposes. It also will not read out cookies from google.com and doubleclick.net. There's the possibility to further redact data when advertising is denied. This is being done automatically by Cookie First as we add the following command.
gtag('set', 'ads_data_redaction', true);