Usercentrics - PUBLIC
Implementing Google Consent Mode with the Usercentrics CMP
The Usercentrics CMP supports Google Consent Mode v2, which Google may require you to implement based on their EU user consent policy. Below youāll find more information about it and how to implement it.
- 1 What is Google Consent Mode?
- 2 Two easy ways to implement GCM with the Usercentrics CMP
- 3 Default consent states for Google Consent Mode storage types in detail
- 4 Updates of consent states for Google Consent Mode storage types
- 5 Step-by-Step Google Consent Mode implementation with the Usercentrics CMP
- 6 Discover more about Google Consent Mode
What is Google Consent Mode?
Consent Mode in essence is a mechanism that allows third party scripts to pass consent data to Google Tag Manager using the Global site tag (gtag) API.
This data can be used to conditionally load tags, or modify their behavior.
Consent Mode is not a Google service or product, itās more like a consent API.
Consent Mode makes use of the dataLayer and only works with Google Tag Manager (or gtag).
Consent Mode is part of the larger Global site tag (gtag) API.
Two easy ways to implement GCM with the Usercentrics CMP
The Usercentrics CMP template tag registers default consent settings, so the consent mode script doesnāt need to be used with that implementation method for the Usercentrics CMP, as long as all relevant Google tags are handled in the Google Tag Manager. (No default consent needed on the page.)
If you donāt implement Usercentrics CMP via the template tag in Google Tag Manager, youāll need to add a script to your page to enable it.
Letās have a look at that script for option 2:
<script type="text/javascript">
// create dataLayer
window.dataLayer = window.dataLayer || [];
//Create the gtag API, so you donāt have to write dataLayer.push() and can use gtag() instead.
function gtag() {
dataLayer.push(arguments);
}
//Use the gtag method to pass default consent settings to Google Tag Manager.
gtag("consent", "default", {
ad_user_data: "denied",
ad_personalization: "denied",
ad_storage: "denied",
analytics_storage: "denied",
wait_for_update: 2000 // milliseconds to wait for update
});
// Enable ads data redaction by default [optional]
gtag("set", "ads_data_redaction", true);
</script>
//The last part is the Google Tag Manager script. If you want to use Consent Mode as alternative to prior blocking the type of the script tag is "text/javascript".
<script type="text/javascript">
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window, document, 'script', 'dataLayer', 'GTM-XXXXX'); //replace GTM-XXXXXX with Google Tag Manager ID
</script>
Default consent states for Google Consent Mode storage types in detail
Consent Type | Description |
ad_storage | Enables storage (such as cookies) related to advertising. |
ad_user_data | Sets consent for sending user data related to advertising to Google. |
ad_personalization | Sets consent for personalized advertising. |
analytics_storage | Enables storage (such as cookies) related to analytics e.g. visit duration. |
In addition to the Consent Mode parameters relevant for Google services, there are the following privacy parameters:
Storage Type | Description |
functionality_storage | Enables storage that supports the functionality of the website or app e.g. language settings. |
personalization_storage | Enables storage related to personalization e.g. video recommendations |
security_storage | Enables storage related to security such as authentication functionality, fraud prevention, and other user protection. |
The Usercentrics CMP does not update the above privacy parameters (functionality_storage, personalization_storage and security_storage) out-of-the-box as they are not part of the built-in consent checks of Google services. To make this connection (if applicable), you can use an event listener similar to the one from Step 2 of our Google Consent Mode tech doc after making sure to include them with the default consent state settings. While technically feasible, please note that this is outside of the support scope for the Usercentrics support & success teams.
Updates of consent states for Google Consent Mode storage types
After the default consent states are set, updates to those will occur when the consent_status of the Google DPS added to the implemented CMP Configuration / SettingID changes.
The updates are automatic, provided:
You are using Predefined DPS for the relevant Google services. A list of the relevant Google DPS for this out-of-the-box way to handle Google Consent Mode is available in our documentation.
You have enabled Google Consent Mode in the Admin Interface of the CMP Configuration, with the relevant toggle under Configuration ā CMP Settings tab ā Google Consent Mode
Ā
If youāre using Custom DPS for relevant Google services:
Follow the optional Step 2 of the Google Consent Mode technical documentation.
Alternative (requires deeper technical GTM expertise): For Google Consent Mode setups purely handled within the Google Tag Manager (GTM), itās also possible to build your own or use third party Google Consent Mode GTM templates. The idea with that approach is to use the consent_status eventās information in the dataLayer to ātranslateā this into Google Consent Mode storage type consent states in the GTM.
Usercentrics does not recommend or actively support this alternative, but it may be feasible for some customers to explore such an option.
Deactivate Google Consent Mode in the Admin Interface of the CMP Configuration. This helps prevent mixed signaling for the consent states.
Step-by-Step Google Consent Mode implementation with the Usercentrics CMP
Youāll find more details above and on the other pages of this Google Consent Mode section, but here are the steps to take for implementing GCM with the Usercentrics CMP put into simple terms.
Set the default consent states for Google Consent Mode storage types in one of two ways:
Using our GTM template tag can do this for you in the Google Tag Manager. Ensure you enable Google Consent Mode in the tag.
Follow Step 1 of our Google Consent Mode tech doc in the context of a direct implementation in your websiteās code.
Regardless of your choice (a or b) above, itās then necessary to: Toggle on / off Google Consent Mode in the Admin Interface of your CMP Configuration / SettingID under Configuration ā CMP Settings tab ā Google Consent Mode, depending on:
Most common use case: If youāre using only Predefined DPS for the relevant Google services, toggle Google Consent Mode on in the Admin Interface to take advantage of our out-of-the-box signaling for GCM storage types.
Optional: If youāre using some Custom DPS for the relevant Google services, follow Step 2 of our GCM tech doc and toggle Google Consent Mode off in the Admin Interface. This helps prevent multiple consent state updates for the GCM storage types.
Adjust triggers of relevant Google tags based on your decision to use Basic or Advanced Google Consent Mode v2.
Discover more about Google Consent Mode
Usercentrics - PUBLIC