Using GDPR Consent Pro with Google Tag Manager

Before you read this guide: You might want to read our Set up guide for Google Consent Mode with GDPR Consent Pro for WordPress (please see next FAQ), which explains how you can setup Google Tag Manager using Google Consent Mode.

This guide helps you to set up the WordPress GDPR Consent plugin in combination with Google Tag Manager. It will allow your visitors to enable/disable (allow/disallow) tags from Google Tag Manager, by accepting/rejecting consents that are set up in your WordPress website using the GDPR Consent Pro Plugin.

Introduction

Google Tag Manager allows organizations to centrally manage the loading of external scripts into a website. Also, the setup of such external services is also outsourced to parties that arrange this activity in its entirety for an organization. From the perspective of the AVG, it is important to have a consent mechanism on a website that can then instruct the Google Tag Manager which consents have or have not been given.

In a nutshell

The GDPR consent plugin allows you to set up consents that visitors can agree to. The plugin places a cookie in the visitor’s browser. This cookie contains ID numbers corresponding to consents given.

In a nutshell

1. Setting up consents in GDPR Consent Plugin

In the GDPR plugin, set up consents that you want to enter. If needed, please read our instructions on how to set up consents.

2. Note the ID numbers of the consents created

When editing a consent in the administration environment of the WordPress website, the ID number can be seen in the address bar of that consent page. Write down the corresponding ID number for each Consent, we will need this later in the Tag Manager.

3. Reading out the consent cookie

The Google Tag Manager can read cookies from the site in which the Tag Manager is loaded.

  1. In the Tag Manager, go to ‘Variables’.
  2. Add a new ‘User-defined’ variable of type ‘Direct Cookie’
  3. Give this variable a logical name (e.g. GDPR Consent)
  4. In the ‘Cookie Name’set the name of the cookie as used on the site. By default, it is ‘gdprc_consents_1’*
  5. Save the variable.

*Please note! With WordPress multi sites, a cookie will be set for each site. The name of the cookie will then be ‘gdprc_consents_’ supplemented by the ID number of the WordPress website within the multisite installation.

4. Creating triggers for consents

In order for the Tag Manager to recognize whether a consent has been issued, we first set up a number of triggers corresponding to the various consents set up on the website.

  1. In the Tag Manager, go to ‘Triggers’
  2. Add a new trigger of type ‘Page view’
  3. Name the trigger after the targeted consent (e.g. ‘Consent – Personalized ads’)
  4. Choose to activate this trigger only for ‘Some page view’ so that a condition can be specified.
  5. In the first field, choose the created variable from the previous step
  6. In the second field, choose ‘matches RegEx’
  7. In the third field, enter the following formula: (?:^||W)XXXX(?:$||W)
    1. Here you replace the XXXX with the number of the consent on which you want to test that consent was issued.
    2. If this website is multilingual, then there is a consent number for each language, for each consent. in this case, replace the XXXX with the consent numbers for each language, separated by a vertical line. This will make this trigger go off regardless of the language the site is visited in.

Repeat until a trigger has been established per consent.

5. Replace existing triggers with trigger groups

In practice, all active Tag Managers are set up to have one trigger per existing Tag. Now, however, more conditions need to be tested before a Tag can be used; both the place where the Tag would fire and whether permission to do so has been given.

This means trigger groups need to be created; in fact, a trigger group can include multiple triggers (conditions) that all need to be true before the trigger becomes active, and a script is loaded for the website visitor.

  1. In the Tag Manager, go to ‘Triggers’.
  2. Add a new trigger of type ‘Trigger group’.
  3. Name the trigger after the intended Tag (e.g. ‘Trigger Group hotjar’).
  4. Add at least the trigger for the consent required to be allowed to load this Tag.
  5. Add any other triggers that may be true before this trigger group goes off.

With a trigger group, all triggers must be true. This becomes visible because there is the word ‘AND’ between the triggers. (If you set this up for a normal trigger, the word ‘OR’ applies – in other words, one or more conditions are then true to fire a trigger).

6. Customize Tags to new trigger groups

The final step is to replace the single triggers in the existing Tags with the newly created trigger groups.

  • Go to ‘Tags’.
  • Click on a tag you want to add to a trigger group you just created
  • Delete the existing triggers in this tag
  • Add the new trigger group.
  • Click ‘Save’.

Perform this for all the tags you want to add to the trigger groups.

Finally: Publish your changes and test if they have the desired effect.

Shopping Cart
  • Your cart is empty.
>
Scroll to Top