Getting started

Load the SDK

Script

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 Didomi Console and get the script tag from the Embed section. Paste the tag the top of the <head> section of your HTML pages, before any other script tag.

Important: Embed our tag before any other tag

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.

React

You can skip this section if you don't have a React application.

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: https://github.com/didomi/react

  1. Install the library using npm.

npm install --save @didomi/react

2. Import the module in your app.

import { DidomiSDK } from '@didomi/react';

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

const didomiConfig = {
app: {
apiKey: '<Your API key>',
vendors: {
iab: {
all: true
}
}
}
}
...
<DidomiSDK
config={didomiConfig}
gdprAppliesGlobally={true}
onReady={didomi => console.log('Didomi SDK is loaded and ready', didomi)}
onConsentChanged={cwtToken => console.log('A consent has been given/withdrawn', cwtToken)}
onNoticeShown={() => console.log('Didomi Notice Shown')}
onNoticeHidden={() => console.log('Didomi Notice Hidden')}
/>

For more information, please check our documentation : https://github.com/didomi/react

Testing from outside the EU

If your banner is configured to not display to non EU visitors, it might be tricky to configure and test if you are not located in the EU yourself. You can use the notice.ignoreCountry: true option if you are testing the banner from the US and force it to be shown to make sure it is working properly.

Another option is to add #didomi:notice.ignoreCountry=true to the URL in your browser bar to force the SDK to ignore the country on the page. Example: If your website is https://www.mywebsite.com, go to https://www.mywebsite.com/#didomi:notice.ignoreCountry=true and the notice should be displayed even if you are not in the EU.

Configure and interact with the SDK

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:

Plain Javascript
React
Plain Javascript
<script type="text/javascript">
window.didomiOnReady = window.didomiOnReady || [];
window.didomiOnReady.push(function (Didomi) {
// Call other functions on the SDK
});
</script>
React
onDidomiReady(didomi) {
console.log('Didomi Ready');
// Call other functions on the SDK
}
...
<DidomiSDK
...
onReady={this.onDidomiReady.bind(this)}
/>

The SDK exposes other events and functions to allow you to interact programmatically with the CMP. Read our Reference section for more information:

Configure vendors and purposes

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 Didomi Console.

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.

Read our dedicated section to learn how to configure your vendors.

Add a link for the user to manage their preferences

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:

Plain Javascript
React
Plain Javascript
<a href="javascript:Didomi.preferences.show()">Consent preferences</a>
React
onDidomiReady(didomi) {
this.didomiObject = didomi;
}
...
<DidomiSDK
...
onReady={this.onDidomiReady.bind(this)}
/>
<button onClick={() => this.didomiObject.preferences.show()}>Consent preferences</button>

We suggest adding this link in your privacy policy or in a header or footer menu on all of your pages.

IAB frameworks

Didomi supports the IAB Transparency and Consent Framework as well as the IAB CCPA frameworks. Read more in our documentation: