Consent Management with Didomi and Google Tag Manager Server
Introduction
In this guide, we’ll show you how to manage consent with Didomi and Google Tag Manager Server (GTM Server) within the framework of an Advanced Consent Mode V2. The goal is to condition your server-side tags based on the user’s consent given through Didomi in the visitor’s browser. For more context, see our general guide on server-side consent management.

Prerequisites
To follow this guide, you must have the following:
- An advanced Consent Mode V2 implementation in your GTM Web container
- A basic knowledge of Google Tag Manager Web and Server
- An active Didomi account with a configured consent banner
- A Google Tag Manager Web container and a Google Tag Manager Server container set up
- Server-side tags already configured in your GTM Server container (for example, a GA4 tag or Meta Conversion API)
Is your website a Single Page Application (SPA)?
Didomi provides dedicated documentation for tracking an SPA with GTM and Didomi: How to track SPA with GTM and Didomi .
Configuring Didomi on your website
Adding the Didomi code to your website
To get started, go to the Didomi console. Inside the consent banner you want to configure, go to the Publish section.

Scroll down to installation step 3, then copy the banner code.

Then paste this code as high as possible in the <head> section of your website, ideally right after the opening <head> tag.
Important
Also make sure that Didomi is loaded before the Google Tag Manager Web script.
<html>
<head>
<!-- Paste the Didomi consent banner code here -->
</head>
<body>
</body>
</html>Configuring Consent Mode
If you send your data to Google Ads, Google Analytics, or Floodlight, you need to enable Consent Mode.
In your Didomi console, inside your banner, go to Customization > Integrations > Consent Modes, then check the Google Consent Mode V2 box.

Leave the Set the default status of Google Consent Mode when the page loads box unchecked. We will manage the default consent mode via the Didomi CMP tag in GTM Web. This ensures that the default consent is set before any of your tags fire in GTM Web.
Then check the following boxes:
- Enable Google Advertising products
- Enable Google Analytics products

Note however that this Consent Mode configuration is generic, and some specifics of your implementation may require additional adjustments.
Configuring the Didomi CMP tag in GTM Web
Adding the Didomi CMP tag in GTM Web
The Didomi CMP tag, available in the GTM template gallery, lets you set the default Consent Mode status before your other tags fire.
Go to your GTM Web container. In the Tags section, click New to create a new tag.

Then go to the community tag template gallery by clicking on the blue banner below.

Search for “Didomi” in the search bar and select the Didomi CMP template published by didomi.

Then add the template to your GTM container by clicking on Add to workspace.

Then confirm adding the template by clicking on Add.
Configuring the Didomi CMP tag
Then configure the tag as follows.

Set Google Consent Mode default status
This section lets you set the default status of the Consent Mode signals. Keep a single row with the Region field empty so that it applies to all regions, and set all signals to denied:
- Ad Storage:
denied - Analytics Storage:
denied - Functionality Storage:
denied - Personalization Storage:
denied - Ad User Data:
denied - Ad Personalization:
denied
Leave the Set all GCM purposes to GRANTED by default - for all regions except EU box unchecked.
Embed Didomi
Leave the Embed the Didomi Web SDK box unchecked. The Didomi banner code is already loaded directly in the <head> of your website as seen previously, so it must not be loaded a second time via GTM.
Note however that this Consent Mode configuration is generic, and some specifics of your implementation (for example, different default statuses depending on the region) may require additional adjustments.
Finally, trigger the Didomi CMP tag on Consent Initialization - All Pages. This trigger ensures that the default consent status is set before all your other tags fire.

Retrieving the consent state in GTM Web
Go to your GTM Web container, in the Variables section, click New.

Then select the Data Layer Variable variable type.

In the Data Layer Variable Name field, enter didomiVendorsEnabled. This is the variable that Didomi pushes to the dataLayer and that contains the user’s consent state.
Name this variable DLV - didomiVendorsEnabled, then save it.
Values returned by the DLV - didomiVendorsEnabled variable
The DLV - didomiVendorsEnabled variable returns a text string containing the vendors to which the user has given consent.
Here is an example of the value returned by this variable:
metaads-xKecBpgc,tiktokan-R4hk2Pmz,pinterestIn this example, the user has consented to the Meta Ads, TikTok Analytics and Pinterest vendors.
Configuring the GA4 Google Tag
The GA4 Google Tag must also send consent information to GTM Server. To do this, you need to add the consent_status event parameter.
Also note that this tag contains the configuration parameters send_page_view set to false and server_container_url with the URL of your server container.
Trigger this tag on the Initialization - All Pages dataLayer event.

Since send_page_view is set to false, the Google Tag no longer sends a page_view event automatically. Instead, it is sent by a dedicated GA4 event tag, triggered on the didomi-consent dataLayer event pushed by Didomi. This ensures that the consent state is available in the consent_status parameter when the page_view is sent.
Create a GA4 event tag with the event name page_view and the consent_status event parameter set to the DLV - didomiVendorsEnabled variable. Trigger it with a Custom Event trigger on the didomi-consent event.

Configuring other GA4 events
With the configuration done in the previous step, all your GA4 events should contain the consent_status parameter that lets you know the user’s consent state. However, it is important to add this parameter to all your GA4 event tags to ensure consent information is always present.
How you trigger the tag depends on when the event is sent: between two page loads, or when the page loads.
Event sent between two page loads: add_to_cart
The add_to_cart event is sent after a user action, once the page has loaded. Didomi has therefore already pushed the consent state to the dataLayer: just add the consent_status parameter to the tag and keep its usual trigger.
Here is an example of the add_to_cart GA4 event tag with the consent_status parameter added:

Event sent when the page loads: view_item
The view_item event is pushed to the dataLayer when the product page loads. It can therefore happen before Didomi has pushed the consent state, in which case the DLV - didomiVendorsEnabled variable would be empty when the event is sent.
To avoid this, the view_item tag must wait for both the view_item event and the didomi-ready event pushed by Didomi. Use a Trigger Group trigger for this:
Create the two triggers
Create a first Custom Event trigger on the view_item event:

Then a second Custom Event trigger on the didomi-ready event:

Create the Trigger Group
In the Triggers section, click New and select the Trigger Group type. Add the two triggers created in the previous step. The Trigger Group only fires once both events have occurred on the page, in any order.

Configure the view_item tag
Add the consent_status event parameter with the DLV - didomiVendorsEnabled variable as its value to your view_item GA4 event tag, then fire it on this Trigger Group.

Configuration in GTM Server
Retrieving the Didomi consent state
To retrieve the consent state in GTM Server, we will create an Event Data type variable that will extract the value of the consent_status parameter sent from GTM Web.
Go to your GTM Server container, then in the Variables section, click New to create a new variable in the User-Defined Variables section.
Then select the Event Data variable type.

Conditioning a server tag on Didomi consent
We will condition the Meta Conversion API by Addingwell tag on Didomi consent. To do this, we will only trigger the tag when the consent_status Event Data variable contains the Meta Ads vendor ID metaads-xKecBpgc.
To know whether you should condition a tag on user consent, refer to your DPO or your legal department.
In the trigger below, we check if the consent_status variable contains the value metaads (the beginning of the metaads-xKecBpgc ID), which indicates that the user has consented to the Meta Ads vendor and all its purposes.

Then add this trigger to your Meta Conversion API by Addingwell tag.

You have now conditioned the Meta Conversion API tag on Didomi consent. You can apply the same logic to condition other tags based on the appropriate vendors.
Watch out for tags already fired before consent
If a user gives vendor consent after browsing several pages, previous events (such as page_view) will not be sent retroactively to Meta. Only events following consent acceptance will be transmitted.
Verifying your implementation
Tag Assistant in Google Tag Manager Web
The first thing to check in the GTM Web preview (or Tag Assistant) is that the Didomi CMP tag fires correctly on all pages, on the Consent Initialization event.
Then check that the DLV - didomiVendorsEnabled variable returns the consent state correctly.
If the value of this variable is empty, it means you haven’t yet given your consent via the Didomi banner. Give your consent to one or more vendors so that the variable returns a value.
Now, interact with the Didomi banner to give your partial consent (one or more vendors) or full consent (all vendors).
Finally, check that the GA4 page_view event tag fires correctly on the didomi-consent event.

And also that the consent_status parameter is present in this tag.

Google Tag Manager Server preview
In the GTM Server preview, check that the consent_status Event Data variable returns the consent state sent from GTM Web correctly on all your events.

Verify the reception of page_view events with the consent_status parameter containing the latest consent value after giving your partial or full consent on the banner.

In this same page_view event, check that the Meta tag, or more generally your tags requiring consent, are properly configured.
If vendor consent has not been given, the Meta tag must not fire. It should then be in the Tags not fired section of your GTM Server preview.
Congratulations
Congratulations! You have successfully set up consent management with Didomi and Google Tag Manager Server. Your server-side tags are now conditioned based on user consent.
If you encounter any difficulty during these steps, do not hesitate to contact our support team.