Custom Didomi <script> tags
Didomi <script>
tags can be used to conditionally load JavaScript tags or other HTML elements on your page.
In this method, you replace your <script type="text/javascript">
tags or any HTML element with <script type="didomi/javascript">
or <script type="didomi/html">
tags and add data-*
attributes determining when the tags should be loaded based on consent given to vendors and/or purposes.
When the Didomi SDK is loaded on a page or when the user gives consent, the tags will be scanned and replaced as follows:
Tag | Replacement |
---|---|
|
|
|
|
The Didomi SDK keeps all the original attributes (including the data-*
attributes) and content from the <script type="didomi/javascript|html">
tags when doing the replacement so no other change than the HTML element is required.
Consent to vendors
The data-vendor
attribute accepts a single vendor ID and conditionally loads a tag when the user enables a vendor and all the purposes required by that vendor.
The data-vendor-raw
attribute accepts a single vendor ID and conditionally loads a tag when the user enables a vendor (does not include its purposes).
Note that enabling purposes with legal basis "Legitimate interest" is not required before loading a tag for a vendor. Read the Consent to purposes section to required consent for specific purposes irrespective of the vendor's legal bases configuration.
Examples
Google Analytics tag:
becomes
The Google Analytics tag is only loaded onto the page when the user gives consent to the vendor Google and all its associated purposes.
How to find your vendor ID?
To find your vendor ID, navigate to the Didomi Console -> Consent notices -> Open your notice -> Regulation -> Edit vendors and Purposes: Use the API ID.
Vendor IDs are unique and are the same across all regulations and notices.
The Didomi Web SDK used to format vendor IDs with a prefix ( prefix:ID,
).
The prefix that were supported:
iab:
for IAB vendors.didomi:
for Didomi vendors.c:
for custom vendors.
To keep backward compatibility, the data-vendor and data-vendor-raw
continue to support prefixed vendor IDs. However it is mandatory to switch to the non-prefixed vendor IDs (i.e API ID) if you are willing to use multiple regulations.
The didomi/javascript
and didomi/html
tags must be placed before the Didomi SDK tag on the page.
If they are not, the Didomi SDK might sometimes miss them if it gets executed before the HTML page is fully parsed.
Didomi <script>
tags cannot be used through Google Tag Manager
Because GTM removes custom tag data-*
attributes when it adds them to the page, you cannot add Didomi <script>
tags in GTM.
Consent to purposes
The data-purposes
attribute accepts a comma-separated list of purpose IDs and conditionally loads a tag when the user enables all the specified purposes.
data-vendor
is the recommended way of conditionally loading a tag as you need the user to enable a specific vendor and its associated purposes. It can be combined with data-purposes
if you want to force consent for specific purposes on top of the vendor's associated purposes. It can be because the vendor has chosen legitimate interest as a legal basis for one or more purposes or because a purpose is not associated with the vendor.
Examples
Google Analytics tag:
becomes
The Google Analytics tag is only loaded onto the page when the user gives consent to the vendor Google, all its required purposes, and the purposes cookies
(Information storage and access) and analytics
(Measurement).
The didomi/javascript
and didomi/html
tags must be placed before the Didomi SDK tag on the page.
If they are not, the Didomi SDK might sometimes miss them if it gets executed before the HTML page is fully parsed.
Didomi <script>
tags cannot be used through Google Tag Manager
Because GTM removes custom tag data-*
attributes when it adds them to the page, you cannot add Didomi <script>
tags in GTM.
Macros
A macro is a string that will be replaced into a certain value once the script is loaded. It can be used to share consent information with partners embedded in didomi/javascript
and didomi/html
scripts.
The available macros are:
Name | Value | Description |
---|---|---|
regulation_name | string | The name of the regulation that applies for the current user.
Possible values: |
| 0 or 1 | Whether GDPR applies to the current request or not |
| string | IAB consent string |
| 0 or 1 | Does the vendor specified in |
| boolean | Does the vendor specified in |
| 0 or 1 | Does the vendor specified in |
| boolean | Does the vendor specified in |
Immediate loading
By default, custom Didomi <script>
tags are loaded on the page after the user gives consent (be it on the same page or on a previous page).
If you want to load these tags on the page immediately, irrespective of the user consent status, add a data-loading
attribute with the value immediate
.
This supports use cases like always loading a tag on a page and passing the current user consent status to it.
Immediate loading should only be used in conjunction with macros in your tags as it allows you to load a tag on page load and get the user consent status through a macro, whether the consent status is positive or negative.
If you are not using macros and enable immediate loading for a tag, the result is the same as keeping a regular <script type="text/javascript">
tag or HTML element on your page as it will always be loaded on the page without conditions.
Last updated