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.

1- Integration

  • To start, you need to activate the GTM integration when you set up the consent notice. 
  • If you use our Console, check the box provided for this integration at the step "INTEGRATIONS":

  • In the field "DATA LAYER NAME", you need to write the name of your data layer.

The standard name "dataLayer" is the one Didomi uses by befault. 

If you kept the standard name, you can leave the field as it is! 

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. 

  • If you didn't use the Console to create your consent notice, you need to add this in the object didomiConfig:
tagManager: {

provider: 'gtm'

}

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

2- Create a variable

  • 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.

  • 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

  • Click on “New file” and name it "Didomi".

  • Click on the three dots on the left of the Didomi file, then "Add a variable".

Google Tag Manager et 15 pages de plus - Personnel – Microsoft_ Edge 2021-06-10 at 10.33.57 AM

  • 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

3- 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:

  • Go in “Folders” in the left menu.
  • Click on the three dots on the right of the Didomi file, then on "Add New trigger".

  • Then enter these information:

Name of the trigger : "{Vendor name} – {Vendor ID}"
Replace what is written between {} by the  name of the matching vendor - cf. “How to find the Vendor ID” further in the article.

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.

  • Save!

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

Then, if your existing trigger was a personalised trigger, you will 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

Otherwise, 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:

  • Go in "Folders" in the left menu.
  • Click on the three dots of the Didomi file, and "Add new trigger".

  • Enter these information:

Name of the group of triggers: Group of triggers - Consent + {name of the other condition} - {Vendor name} – {Vendors ID}
Replace what is written between {} by the matching information

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).

  • 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.

 

 

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.

 

⚠️ 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”

Google Advertising Product: “didomi:google”

Amazon: “didomi:amazon”

Twitter: “didomi:twitter”

4- 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: 

  • Click on one of your existing tags concerning a non-IAB vendor.
  • Add the trigger or the group of triggers (created previously) matching with the vendor of the tag, instead of the trigger used beforehand. 
  • 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.