Google Tag Manager implementation
In order to enable Google consent mode v2 on your website, you need to have a cookie banner solution in place. If you already have a Cookiebot CMP subscription, the Cookiebot script will automatically send the appropriate signals to Google on consent submission. You will manually need to ensure that a default state is set though.
Ensure that you have enabled Consent Mode (see image below) and have the template updated to the newest version. If you want to implement Cookiebot via the Cookiebot CMP Template Gallery Tag inside Google Tag Manager (GTM), please refer to our GTM deployment guide instead.
Wordpress implementation
Install the Cookiebot Wordpress plugin and ensure that you have enabled consent mode (see image below) and have the plugin updated to the newest version.
Inline script implementation
The Google consent mode is an API which Cookiebot CMP integrates with.
When you have installed the Cookiebot CMP tag directly on your site, you can set default (prior consent) settings via the Google consent API-integration by adding the following code snippet to your website template.
<script data-cookieconsent="ignore"> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag("consent", "default", { ad_personalization: "denied", ad_storage: "denied", ad_user_data: "denied", analytics_storage: "denied", functionality_storage: "denied", personalization_storage: "denied", security_storage: "granted", wait_for_update: 500, }); gtag("set", "ads_data_redaction", true); gtag("set", "url_passthrough", false); </script>
URL passthrough
When a user rejects cookies, there is a fallback solution to pass the data that would normally be stored in the "_ga" cookie by adding it to the URL as a query parameter.
To enable this, set URL passthrough to "true" with gtag("set",
"url_passthrough", true);
Renaming the dataLayer
If you've chosen to rename the dataLayer, please ensure that you modify the script to use the new name of the dataLayer.
For example, if you renamed the dataLayer to "gtmDataLayer", the first line needs to be amended to resemble this: window.gtmDataLayer = window.gtmDataLayer || [];
Default values
Default consent can be set per region. You may change the values of the default consent types to "granted" or "denied" if you want to default to an opt-in before the end user has submitted consent, for example allowing for a default opt-in under CCPA.
Trigger configuration
If you previously applied cookie consent triggers to tags with "built-in consent" (such as Google Ads, Analytics, Floodlight and Conversion Linker), you can once again use default triggers like "All pages".
Consent mode and TCF
If you use TCF 2.2 in addition to Google consent mode; A TCData update (TCData.enableAdvertiserConsentMode
) allows Google to infer ad_storage, ad_personalization, and ad_user_data settings from the TC string. This will incorporate consent mode v2 updates directly into the TC string.
However, to mitigate potential issues related to network loading times, we recommend additionally implementing the consent mode script with the default consent states manually to ensure that no Google tags can fire without consent.
Comments
3 comments
What happens if I don't implement Google consent mode?
Yes, I'm curious as well...
What happens if we don't implement Google Consent Mode v1/v2?
@Edward from the email that Google sent out if you are an Ads user:
Please sign in to leave a comment.