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:

  1. An account in Google Tag Manager (GTM),
  2. 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.

Script Blocking-GTM Disabled
Script Blocking-GTM Disabled

Following will detail the steps involved in attaining GDPR Compliance using GTM:

  1. Create a Trigger in GTM
  2. Insert GTM compatibility code snippet in the active theme

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:
    GDPR GTM Compatibility-Trigger Configuration
    GDPR GTM Compatibility-Trigger Configuration
  • Repeat the above for each cookie category, for example, for non-necessary the event name can be given as “CLI.consent.non_necessary“, and for marketing, it can be given as “CLI.consent.marketing” and so on.
  • Now open the Tag configuration window and link the trigger you have just created from the triggering section. If any trigger was previously linked, it has to be removed prior to linking the newly created trigger. For instance, link the trigger Analytics with Google Analytics: Universal Analytics tag.
  • Click “Save” to create or update the tag.
  • This is what your final tag configuration pane will look like (except for the Tracking ID):
    GDPR Consent GTM Compatibility-Tag Configuration
    GDPR Consent GTM Compatibility-Tag Configuration
  • Finally, click “Publish” to push your changes live to your site.

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 replaceEventName with the actual event name given while creating a trigger.

ie:  For category analytics, you can insert the snippet in the following manner:

where the category slug is analytics and the event name is cli_cookieconsent_analytics

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, sample code snippet with three categories (as specified above) will look like:

Leave a Reply

Your email address will not be published. Required fields are marked *