1. Help Center
  2. Consent Notices

Block your tags with our Google Tag Manager integration

This article aims to guide you through the integration that Didomi offers with Google Tag Manager (GTM) to set up the loading of tags that are present on your website when there is consent from the user.

Introduction - Presentation of the events and variables sent in the Data Layer

The GTM integration enables the Didomi SDK to send events. The latter can generate variables, in the GTM Data Layer. 

  • Didomi Events

didomi-consent: when the page has loaded and everytime there is a consent change.

didomi-ready: when the page is loaded.
didomi-consent-changed: when there is a consent change.

We recommend to use the didomi-consent event, as it "contains" the two other ones. So it's usually the most suitable in most cases.

You can find these events in our 📰 technical documentation

  • Didomi Variables

Didomi events will generate Didomi variables in the GTM Data Layer.

The Didomi variables include the following information about :

  • Vendors (vendors that got consent from the user)
  • Purposes (what purposes were accepted for consent)
  • the IAB and the GDPR (where GDPR applies)

You don't have to use all these variables. The most used variable "didomiVendorsConsent", that holds the list of all vendors that got the user's consent.

You can find the variables 📰 here.

The goal is to use these events and variables in the triggers you will create, to activate the loading of tags only if the user has given his consent. A trigger is actually activated depending on the event and the variable.


To start, you need to activate the GTM integration when you set up the consent notice. 
  1. If you use our Console, check the box provided for this integration at the step INTEGRATIONS:
    Didomi Compliance Console et 11 pages de plus - Personnel – Microsoft_ Edge 2021-06-29 at 10.40.51 AM
  2. In the field "DATA LAYER NAME", write the name of your data layer.
  3. The standard name "dataLayer" is the one Didomi uses by befault. 
  4. If you kept the standard name, you can leave the field as it is! 
  5. If you renamed it though, you can see it in the code of your website/ask your tech team), you will need to write the right name in the DATA LAYER NAME field. 
  6. If you didn't use the Console to create your consent notice, add this in the object didomiConfig:
  7. tagManager: {

    provider: 'gtm'

  8. If you checked the box in the console, don't add this code. 

Create a variable

  1. Go on your Google Tag Manager account.
    👉 We are going to start off by creating a variable "didomiVendorsConsent", that is the most used one. It will enable you to set up the loading of the tag when consent is given by the user for each vendor.
  2. Go in Folders on the left menu.
    Google Tag Manager et 15 pages de plus - Personnel – Microsoft_ Edge 2021-06-10 at 10.23.57 AM
  3. Click on New file.
  4. Name it "Didomi".
  5. Click on the three dots on the left of the Didomi file.
  6. Click on Add a variable.
    Google Tag Manager et 15 pages de plus - Personnel – Microsoft_ Edge 2021-06-10 at 10.33.57 AM
  7. Enter these information:

Name: Didomi Vendors Consent (instead of “ variable without title”)
Type of Variable: Variable of the Data Layer (use the pencil icon to open the choice menu).
Name of the variable of the data layer: didomiVendorsConsent

Create triggers

You then need to create triggers and connect them to one of the Didomi events (we recommend you to use didomi-consent) and to the variable called Didomi Vendors Consent (created beforehand, cf. last step).

You need to create a trigger for each non-IAB vendor that you want to block.

To create a trigger:

  1. Go in Folders in the left menu.
  2. Click on the three dots on the right of the Didomi file.
  3. Click on Add New trigger.
  4. Then enter this information:

Name of the trigger : "{Vendor name} – Didomi", for example
Replace what is written between the {} with the name of the corresponding vendor (and remove the {})  
The name of the trigger does not have any impact, you can enter the name that you prefer.

Type of trigger : custom event (use the pencil icon to open the choice menu)

Name of the event : one of the events generated by Didomi (didomi-consent, didomi-ready or didomi-consent-changed). We recommend to use didomi-consent.
"Conditions in which the trigger can be executed": tick “Some custom events”.

"Fire this trigger when an event occurs and all of these conditions are true": Didomi Vendors Consent        contains        {ID du vendor}

Replace what is written between {} by the corresponding vendor ID : cf. “How to find the vendor ID” a little further in this article.

Repeat this for all non-IAB vendors you own. You need to create a trigger per non-IAB vendor.

👉If your existing trigger was a personalised trigger, you need to "create a group of triggers", so that the tag gets activated when the condition 1 (the existing one) and the condition 2 (the one linked to consent) both meet

👉If you add both the existing trigger linked to consent AND the existing trigger, to the tag, the latter will be launched when the condition 1 OR 2 is valid. But it doesn't need to be both of them at the same time, which would generate a deposit of cookies before/without consent (no compliancy). 

To create a group of triggers:

  1. Go in "Folders" in the left menu.
  2. Click on the three dots of the Didomi file, and "Add new trigger".
  3. Enter this information:
  4. Name of trigger group: "Group of triggers – Consent + {name of the other condition} - {vendor name}", for example
    Replace what is written between the {} with the corresponding information (and remove the {})
    The name of the trigger group does not have any impact, you can enter the name that you prefer.

    Type of trigger: Click on the pencil icon and choose "Group of triggers".

    Click on ,  on the right of “Triggers”.
    Select the existing trigger of your tag.
    Click on   again.
    Select the Didomi trigger matching the vendor, created beforehand (cf. previous step).
  5. Save!

👉This trigger (or group of triggers) can now be used in tags so that they get activated whenever the user gives his consent for this vendor. 

Trigger groups are triggered once per page only, which can be problematic when using dynamic websites.

In that case, you can use our functions and events. And in the specific context of a SPA, you can refer to our dedicated GitHub page.


Where to find the vendor ID? 

To find the vendor ID, go on your Didomi console at the "Vendors and Purposes"  section and copy the SDK ID given in the last column.

Screen Recording 2021-07-01 at PM


⚠️ Be careful, there's a specific case for 4 vendors:

For Facebook, Google Advertising Product, Amazon and Twitter, you need to add the prefix “didomi:” before the ID given in the last column:

The correct IDs are...

  • Facebook: “didomi:facebook”
  • Amazon: “didomi:amazon”
  • Twitter: “didomi:twitter”
  • Google Advertising Products: “didomi:google” (this case will not be necessary if you use our TCF integration, as Google Advertising Products is an IAB vendor)

Match the trigger to the tag

Finally, you need to connect the trigger to "its" tag. This last step is very important!

In the "Tags" section of your GTM account: 

  1. Click on one of your existing tags concerning a non-IAB vendor.
  2. Add the trigger or the group of triggers (created previously) matching with the vendor of the tag, instead of the trigger used beforehand. 
  3. Save!

⚠️ Do so for EACH of the existing triggers concerning the non-IAB vendors. 

Remember to set up the tags of all your containers.

From now on, each time you will add a new tag for a non-IAB vendor that requires a GDPR compliant consent, you will need to go through the setup and tick this new vendor in the list displayed on the console.