Getting started
Last updated
Last updated
We offer the Didomi SDK as a hosted JavaScript library that you can directly include on your website with a <script>
tag.
Create a Consent Notice in the and get the script tag from the "3. Publish" section. Paste the tag the top of the <head>
section of your HTML pages, before any other script tag.
Important: We recommend that you integrate the tags in the following order:
Conditioned vendors tags (header)
Didomi SDK (header)
Non conditioned vendors tags
Make sure to add the tag as close to the opening <head>
tag on your page as possible, before any other tag gets embedded
Keep in mind that the role of our JavaScript SDK is to share consent information with all the other scripts on the page. In order to do so, it MUST be placed before any other tag or the tags from your vendors will not be able to collect consent information from us. Put it as close as possible to the opening <head>
tag. If our SDK gets included after the other tags then the consent information will not be correctly shared and you will not be compliant with the GDPR requirements.
Hybrid Apps: If you are embedding our tag as part of your hybrid app (Electron, Cordova, etc), make sure to as part of the configuration object.
We also provide a React component to simplify the integration of our SDK with React applications. To use it, please follow the steps below or go directly to our React component documentation:
Install the library using npm.
2. Import the module in your app.
We recommend instantiating the component as soon as possible: the sooner you instantiate the component, the faster the banner will be displayed or the faster the consents will be shared with your partners and the ads displayed.
3. Instantiate the component in your app
The SDK will automatically pull the notice configuration from the Didomi Console.
Add the following code to your Web based CTV app. We recommend to embed it directly in the source of your HTML pages as adding it through a tag manager would slow down the loading of the notice.
Your website will automatically pull the latest configuration based on the notice ID provided.
Supported Web based CTV devices
Below is the list of supported devices:
Tizen OS 3.0 and above
HbbTV 1.5 and above
webOS 4 and above
Once the SDK has loaded, you can call other functions on it to do consent management, send analytics events, etc. To make sure that you use the SDK when it is ready, you can register a global didomiOnReady array of functions that will get called when the SDK is done loading:
The Didomi SDK automatically creates a <div>
element with the ID didomi-host
, where the SDK will render its content. By default, this element is appended at the end of the <body>
element of your webpage.
Although we recommend using the default setup, you can optionally create and manage the didomi-host
element yourself if your project requires additional control over its configuration. For instance, you may want to adjust the text direction, add custom CSS classes, or modify attributes for accessibility or SEO purposes.
Here is an example of how to manually define the host element:
Note: Even if you manage the didomi-host
element yourself, the SDK will control the following properties to ensure functionality and compliance:
data-nosnippet
: Prevents Google from using the CMP UI in search results.
aria-hidden
: Ensures the Didomi notice is correctly highlighted for screen readers, improving accessibility.
If you customize the didomi-host
element, ensure it is properly styled and positioned to avoid display issues.
Avoid removing or overriding the SDK-managed attributes (data-nosnippet
and aria-hidden
) to maintain compliance with SEO and accessibility guidelines.
While we interoperate with a lot of vendors through the IAB framework or direct integrations, vendors that do not fall into either of these buckets must be configured through our tag manager or your existing tag manager. Failure to do so will result in vendors not being correctly blocked as needed and you will not be compliant with data privacy regulations.
After the user has given consent or closed the banner, you must given them an easy access to their choices so that they can update them.
You can use the function Didomi.preferences.show()
to open the preferences manager and let the user update her choices. Example:
We suggest adding this link in your privacy policy or in a header or footer menu on all of your pages.
Didomi supports the IAB Transparency and Consent Framework as well as the IAB CCPA frameworks. Read more in our documentation:
For more information, please check our documentation :
Make sure that the notice that you will setup has been marked as CTV type (rather than Web) on the Console. See for more information.
You will need to replace {{SDK-URL}}
with our default SDK URL: or .
You will also have to replace the {{Your-API-Key}}
and {{Notice-ID}}
parameters with your API key and your notice ID respectively.
The SDK exposes other events and functions to allow you to interact programmatically with the CMP. Read our section for more information:
As per GDPR, the consent notice collects consents for a specific set of vendors and purposes. You must configure the notice to let it know what vendors are used on your website and it will automatically determine what purposes are required. This can be done from the .
Read our dedicated section to .