One of the constant questions many digital marketing teams in the European Union had to face prior to May 25th, 2018 – GDPR deadline day, was: “How is our website GDPR compliant?”. Not only was this a question for European companies but anyone with EU users to their site or app. Many websites now have implemented Cookie Consent notifications. This should have already been present previously, yet with GDPR there is a requirement to make these Optin-In and not just a notification.
By default, we must set Remarketing and Advertising Reporting Features to “Off” in Google Analytics. Now we will go about setting up Google Tag Manager to dynamically turn these settings on using our Cookie Consent form.
Is your Cookie Consent set up GDPR compliant?
So you have a Cookie Consent popup bar, sticky bar, and full-blown popup. How do we ensure that we only track visitors that click “Allow Cookies” or “Accept” to be tracked for the purposes of Remarketing or Audience creation using Google Analytics?
Google has a setting in Google Analytics that we will invoke using our Cookie Consent form.
Getting Started – Checklist
Let’s assume that you have the following setup on your website:
- Google Tag Manager is deployed on all page loads.
- You are using the Google Tag Manager to load your Universal Google Analytics tracking.
- You have a Cookie Consent Popup or Notification Bar that has “Allow” or “Deny” options.
How to create Cookie Consent settings using Google Tag Manager
Identify your cookie variable
Open up your website and using your web browser developer tools to view the Cookies being loaded by your site. Ensure you have deleted your Consent Cookie already. Now click on your notification cookie to “allow” or “accept” cookies. Reload the page and note the value this sets.
In the case of my cookie consent form. The value that is set is “allow”.
Set your Cookie Variable in Tag Manager
We need to set up a two new variable in Google Tag Manager to feed the value to the data-layer as Google Analytics requires a value of “true” to set the allowAdFeatures.
Firstly, lets set up our 1st party cookie variable.
I’ve called mine “Cookie Consent Status”.
Save the variable and move along to the second step.
Building a Lookup Table in Google Tag Manager for your Cookie Consent value
We must make a Lookup Table Variable. We need a Lookup Table Variable to convert our Cookie Consent Status value. The output value from our Cookie Consent form may be different from what Google Analytics requires for setting allowAdFeatures. Using a Lookup Table Variable we will convert our input values into either true or false for Google Analytics to be able to set the allowAdFeatures.
We will give our variable a name like “Lookup Cookie Consent Status for GA”
We only require one input value of “allow” (in the case of my cookie consent form) to output “true”.
Set the default value to “false” as we are building a GDPR compliant Cookie Consent action. Setting a default value will ensure that we will only set “allowAdFeatures” to true when the user consents explicitly.
Dynamically setting the output value from your lookup variable to set “allowAdFeatures”
Next, we need to navigate to our Google Analytics tag in Tag Manager.
Under More Settings, add a Field Set.
Field Name = allowAdFeatures
Value = {{Lookup Cookie Consent for GA}} or whatever you choose to name your Lookup Table Variable.
Save your settings and we should be ready to test that your cookie consent notification is now passing its value into Google Tag Manager where it is converted into a value for Google Analytics to dynamically set the “allowAdFeatures” to true if consent has been given by the user.
Test Your New Cookie 🍪 Deployment In Debug Mode
Lastly, you must test that the changes you have made are working correctly. Using either the Debug mode in Google TagManager or the Google TagManager Browser Extension you can turn on Debug mode. Once you have Debug mode on, navigate to your site and launch the Developer tools to view the console output for Google Analytics. If you see the allowAdFeatures setting being output as true or false, ensure this aligns with the Cookie setting for accepting cookies or declining them.
Leave Your Feedback On Cookie Consent Methods
I’d love to hear from you if this article was of any help you. If there are any improvements I could make to the content or any different ways of implementing this technique, please leave a comment below.
Don’t forget to share this article if you think it would benefit others with becoming GDPR compliant.