Comment on page

Other tag managers

This section explains how to integrate Didomi with any tag manager that we do not have a direct integration with. This allows you to to use consent information in rules when deciding whether a tag can be loaded or not directly from your tag manager.
Didomi stores variables on the window.didomiState object with the consent information from the user. A custom tag manager integration requires passing that consent information to the data layer of the tag manager, to be able to create tag-loading rules based on the user consent status.
With this guide, you will:
  • Pass consent information from Didomi to the data layer of your tag manager
  • Create rules in your tag manager to only load tags when consent
  • Delay loading of your tag manager and/or tags that require consent

Configure the integration

Step 1 - Website configuration

Option A - Dynamic data layer - Update the data layer on your website

If your tag manager supports dynamically passing variables to the data layer after page load, this is the best option to leverage as you will not need to delay your tag manager initialization.
The Didomi SDK stores a copy of the user consent status in variables on the window.didomiState object. To get started, update the data layer on your website to pass variables from Didomi to your tag manager after the Didomi SDK is ready:
<script type="text/javascript">
window.didomiOnReady = window.didomiOnReady || [];
window.didomiOnReady.push(function (Didomi) {
window.updateDataLayer({
// Didomi variables
didomiGDPRApplies: window.didomiState.didomiGDPRApplies,
didomiIABConsent: window.didomiState.didomiIABConsent,
didomiVendorsConsent: window.didomiState.didomiVendorsConsent,
didomiVendorsConsentUnknown: window.didomiState.didomiVendorsConsentUnknown,
didomiVendorsConsentDenied: window.didomiState.didomiVendorsConsentDenied,
didomiPurposesConsent: window.didomiState.didomiPurposesConsent,
didomiPurposesConsentUnknown: window.didomiState.didomiPurposesConsentUnknown,
didomiPurposesConsentDenied: window.didomiState.didomiPurposesConsentDenied,
didomiExperimentId: window.didomiState.didomiExperimentId,
didomiExperimentUserGroup: window.didomiState.didomiExperimentUserGroup,
};
});
</script>
updateDataLayer is an example function name. Your tag manager will have its own way of passing custom variables to the data layer dynamically.
Notice how the data layer is updated in a didomiOnReady handler. This guarantees that the Didomi consent status is available in the didomi* variables when the data layer for your tag manager gets updated.

Option 2 - Static data layer - Update the data layer on your website

Some tag managers load variables into the data layer only on page load and do not have an option to dynamically pass variables later in the page lifecycle. As a result, you will need to update your website configuration to delay loading the tag manager and set the dataLayer variable only after Didomi is loaded on the page.
The Didomi SDK stores a copy of the user consent status in variables on the window.didomiState object. To get started, update your dataLayer JavaScript on your website to pass variables from Didomi to your tag manager after the Didomi SDK is ready:
<script type="text/javascript">
window.didomiOnReady = window.didomiOnReady || [];
window.didomiOnReady.push(function (Didomi) {
window.dataLayer = {
// Keep your existing variables here
firstVariable: 'content',
secondVariable: 'content',
...
// Add Didomi variables
didomiGDPRApplies: window.didomiState.didomiGDPRApplies,
didomiIABConsent: window.didomiState.didomiIABConsent,
didomiVendorsConsent: window.didomiState.didomiVendorsConsent,
didomiVendorsConsentUnknown: window.didomiState.didomiVendorsConsentUnknown,
didomiVendorsConsentDenied: window.didomiState.didomiVendorsConsentDenied,
didomiPurposesConsent: window.didomiState.didomiPurposesConsent,
didomiPurposesConsentUnknown: window.didomiState.didomiPurposesConsentUnknown,
didomiPurposesConsentDenied: window.didomiState.didomiPurposesConsentDenied,
didomiExperimentId: window.didomiState.didomiExperimentId,
didomiExperimentUserGroup: window.didomiState.didomiExperimentUserGroup,
};
});
</script>
dataLayer is an example variable name. Your tag manager will have its own naming for data layer variables.
Notice how the dataLayer variable is defined in a didomiOnReady handler. This guarantees that the Didomi consent status is available in the didomi* variables when the external variables for your tag manager get registered.

Step 2 - Delay initializing your tag manager

If you are using a static data layer, you will need to delay the initialization of your tag manager to make sure that the user consent status is available in the data layer when tags get evaluated and loaded.
If you are using a dynamic data layer, you usually do not need to implemented this step.
Didomi creates the window.didomi* variable when the SDK is done loading. You must delay your tag manager until Didomi is ready or the variables holding the consent status will be undefined.
To delay your tag manager, update your <script> tags that load your tag manager to execute after Didomi is loaded. For instance:
<script type="text/javascript" src="/path/to/tagmanager.js"></script>
becomes:
<script type="didomi/javascript" src="/path/to/tc_script.js"></script>
Notice how we replaced the script type text/javascript with didomi/javascript. This will ensure that your tag manager only gets included after Didomi is ready.
Read our documentation for more information on this feature.

Step 3 - Create rules in your tag manager

Now that your data layer is setup, you are able to access the user consent status collected by Didomi in your tag manager.
You need to create rules on your tags that require consent to only load after consent is given by the user. How to do that depends on your tag manager and we can only provide a generic outline of the setup.
Generally, you will create rules that depend on the didomiVendorsConsent and that constrain a tag to be loaded only if that variables contains a specific value indicating that the user has given consent for that vendor.
For instance, if you want to load Google Analytics only if the user has given consent to the vendor Google, you will create a rule on your Google Analytics tag that only embeds it into the page if the didomiVendorsConsent data layer variable contains "didomi:google,".

Didomi variables

Here is a comprehensive list of the variables exposed by Didomi and their content.

Vendors

These variables contain the consent status of the user for every vendor that you have defined in your configuration.
The consent status reported for vendors automatically includes the status for their required purposes. You usually do not have to create a rule that uses both vendors AND purposes variables and a rule on vendors is enough.
Example: didomi:google is only included in the list of vendors that the user has given consent to if the user has given consent to didomi:google and to every purpose required by that vendor.
Vendor IDs reported in variables are prefixed
  • iab: for IAB vendors (ex: iab:1)
  • didomi: for Didomi vendors (ex: didomi:google)
  • c: for custom vendors (ex: c:vendor-id)
Variable
Description
Values / Example
didomiVendorsConsent
A comma-separated list of vendors that the user has given consent to. We use the list of purposes declared for the vendor to make sure that it has consent for all of them. The list includes prefixes (iab: for IAB vendors ,didomi: for Didomi vendors and c: for custom vendors) and is terminated by a final comma. Rules on this variable should check if the variable contains prefix:ID, to guarantee that there is an exact match and avoid a confusion between vendor prefix:1 and vendor prefix:10.
iab:1,iab:2,didomi:google,c:custom,
didomiVendorsConsentUnknown
A comma-separated list of vendors that the user has not yet given/denied consent to.
iab:1,iab:2,didomi:google,c:custom,
didomiVendorsConsentDenied
A comma-separated list of vendors that the user has denied consent to.
iab:1,iab:2,didomi:google,c:custom,

Purposes

These variables contain the consent status of the user for every purpose that consent is collected for. You usually do not need to use these variables directly and want to use the Vendors variables instead.
Variable
Description
Values / Example
didomiPurposesConsent
A comma-separated list of purposes that the user has given consent to.
cookies,analytics,
didomiPurposesConsentUnknown
A comma-separated list of purposes that the user has not yet given/denied consent to.
cookies,analytics,
didomiPurposesConsentDenied
A comma-separated list of purposes that the user has denied consent to.
cookies,analytics,

GDPR & IAB

Variable
Description
Values / Example
didomiGDPRApplies
Define whether the GDPR applies to the current user (ie the user is located in the EU or your website is configured to enforce GDPR for all users).
0 (GDPR does not apply) and 1 (GDPR does apply)
didomiIABConsent
The IAB consent string as defined in the Consent String and Vendor List Format specification. It encodes the consent information for every vendor and purpose as well as few other pieces of information on the CMP that created the string.
BOMi0lyOMi0lyAHABBENAC-AAAAB4AQABaA

AB tests

We expose variables that the contain the status of the AB test running (if any). That allows you to track your AB tests results through your own analytics solution.
Variable
Description
Values / Example
didomiExperimentId
ID of the AB test running.
The value of the experiment.id property in your SDK configuration. An empty string is provided if there is no test configured.
didomiExperimentUserGroup
The group that the user is a part of.
control if the user is part of the control group
test if the user is part of the user group
An empty string is provided if the user is not part of the control or test group.