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.

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>

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>