How to attain GDPR compliance by using Google Tag Manager
You can easily make your use of Google Tag Manager GDPR compliant with our cookie consent plugin. The GDPR Cookie consent plugin helps you to make your use of cookies and online tracking compliant with the EU-legislation on personal data and online privacy.
The pre-requisites for using Google tag manager are:
- An account in Google Tag Manager (GTM),
- Created a website container in GTM
Note:
The Google Tag Manager must be disabled from the dashboard prior to inserting the script into the theme or else the script blocker as a whole can also be disabled.

Following will detail the steps involved in attaining GDPR Compliance using GTM:
Create Triggers
The Triggers can be configured in the following manner:
- From the GTM “Triggers” list, click “New”.
- Choose “Custom Event” and enter an event name for the trigger, for example for category analytics you can enter the event name as “cli_cookieconsent_analytics”, in the field “Event name”.
- Click “Save” to create the trigger and assign a name for the trigger, say Analytics.
- This is how the trigger configuration pane will look like:


The category associated in this manner will only set cookies if the visitor has accepted consent.
Insert GTM compatibility code snippet in the active theme
Next step would be to insert the code snippet into the active theme header file (header.php). The syntax of the code snippet for attaining GTM compatibility is as shown below:
In the above syntax, replace cookie_category_slug
with the actual category slug name and replace EventName
with the actual event name given while creating a trigger.
ie: For category analytics, you can insert the snippet in the following manner:
Note: If the category slug is a hyphenated word, then it must be replaced by an underscore. That is, for category non-necessary, the category slug can be entered as non_necessary.
For example, a sample code snippet with three categories (as specified above) will look like this:
Comments (14)
Agnes
December 4, 2020
I am having troubles to get the info show in the data layer.
It would be great to have this included in the plugin, mapped with the categories we have, interacting directly in WP.
Jeff
October 17, 2020
Could I please know the callback function for Reject?
Jeff
October 16, 2020
I’m also looking for returning a callback for the Reject function. Does anyone have a solution?
Hans Palmers
October 16, 2020
How does the code snippet look like for multiple language sites?
The cookie categories are translated and therefore have different slugs, yet these slugs are needed to load the code snippet (?), to fire the events & trigger the scrips such as Universal Analytics.
Mark
October 17, 2020
As mentioned at the end of the WPML set up guide for the plugin(check in our documents section), please make the slugs of the translated categories the same.
Agnes LESAGE
October 15, 2020
Hi, it would be best if the code could be included in the header in WP plugin, and this way it could also be based on the categories we create.
Graham Carroll
October 7, 2020
Is it essential to add a cli_cookieconsent_necessary GTM trigger to fire the “necessary” cookies? Thanks.
Mark
October 9, 2020
That would depend on the whole configuration. We cannot give a yes or no answer to that.
Please submit a ticket via support for site specific assistance.
Jimena
May 5, 2020
By using this solution with GTM, do I have to purchase the plugin or this also applies for the free version? Or the free version doesn’t allow to integrate with GTM ?
Mark
May 6, 2020
It only works with the premium version. If you need to manage GTM with free version, you can add the script of GTM in head/body area under the Non-Necessary script area. There won’t be any granular control for the scripts inside GTM though.
Maxwell Hogan
January 4, 2020
I have a solution for obtaining reject. All good.
Andrew Wright
January 9, 2020
What is the solution?
Jeff
October 16, 2020
Hi, can you please share your solution?
Maxwell Hogan
January 3, 2020
What is the function for returning a callback of Reject as well?