Google Consent Mode

Google Consent Mode allows you to adjust how your Google tags behave based on the consent status of your users.
The Didomi CMP can indicate to Google whether consent has been granted for Analytics and Ads cookies. Google's tags will dynamically adapt, only utilizing tools for the specified purposes when consent has been given by the user.
The Google Consent Mode only works with gtag.js (and not with the legacy tags such as ga.js, analytics.js or conversion.js). To make sure that the Google Consent Mode integration works properly, make sure that you switch to gtag.js.
Didomi currently provides two different ways to enable GCM.
If you are enabling Consent Mode and you have enabled our custom GTM integration in the past, make sure to take a look at the documentation since using Consent Mode in conjunction with conditional loading will impact its functionality given that Google consent-aware tags would not fire unless consent is granted.
This is the most performant (fastest) and recommended way available to enable Google Consent Mode. In order to configure it and use our custom GTM template, you can follow these instructions.
Google Consent Mode can be enabled via the integrations.vendors property in the Didomi configuration object:
<script type="text/javascript">
window.didomiConfig = {
integrations: {
vendors: {
gcm: {
enable: true
}
}
}
};
</script>
Google Consent Mode allows you to configure the default status for the two Google Consent Mode purposes (analytics_storage and ad_storage). This is the status that is propagated to the Google Consent Mode integration on the initial page load. You can read the full reference about the Google Consent Mode default behavior in the official documentation from Google.
Didomi CMP enables you to set the default status for the Google Consent Mode integration purposes (analytics_storage and ad_storage):
<script type="text/javascript">
window.didomiConfig = {
integrations: {
vendors: {
gcm: {
enable: true,
setDefaultStatus: true,
defaultStatus: {
analytics: false, // 'analytics_storage' default status
ad: false // 'ad_storage' default status
},
}
}
}
};
</script>
The Didomi CMP listens to the consent status updates of the Google Advertising Products (SDK ID: google) and Google Analytics Products (SDK ID: c:googleana-4TXnJigR) vendors to update the status of ad_storage and analytics_storage purposes in the Google Consent Mode integration.

Configuring Google tags

When Didomi should set the default value for Google Consent Mode ( setDefaultStatus flag value is set to true in the Didomi configuration object), the gtag.js script should have didomi/javascript type to make sure that it is loaded after the Web SDK is loaded on the page:
<script type="didomi/javascript" src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
The didomi/javascript tag should be applied to all script tags that rely on Consent Mode or gtag.js to make sure they are not executed before the default consent settings are available or before the gtag.js library is available. For more information read the Custom Didomi <script> tags documentation below.
Read our Custom Didomi <script> tags section for more information about didomi/javascript configuration:

Custom data layer name

By default, Didomi uses window.dataLayer as the variable name for your Google Tag Manager data layer. The same data layer name is used for the Google Consent Mode by default.
If you have renamed your data layer name (https://developers.google.com/tag-manager/devguide#renaming), you can instruct Didomi to use another variable name for the Google Consent Mode integration:
<script type="text/javascript">
window.didomiConfig = {
integrations: {
vendors: {
gcm: {
enable: true,
dataLayerName: 'customDataLayer' // Custom data layer name, defaults to 'dataLayer'
}
}
}
};
</script>