EU Cookie Consent With Google Tag Manager

Important Notice: This guide is not really meant to be followed step by step as it is a very custom solution. Instead take the information provided and use pieces or just take it as inspiration.

Technical Marketing Guide back in 2018, created and shared there way to use Google Tag Manager to manage external cookies and the cookie bar, I have taken the important parts from their page and re-posted below, you can find the original post here.

If you want to use some of the code, here’s a little FAQ:

  • Adjust the “Cookie Base URL” Macro to match your URL otherwise the cookies won’t set correctly.
  • There are a couple “Example” Tags included to show you how your tags need to fired with this approach.
  • Be sure to update the “Cookie Bar Text” variable to adjust the text and links accordingly.
  • Adapt the “Cookie Settings Pageview” Trigger to match your cookie-settings page – this trigger and the Tag “Settings Seen Cookie” will save the settings when they are only “viewed”. This Tag would be optional – I just found it helped the user experience.

This is the markup for the “cookie settings” page:

You could just use that code within a page and it should work.

<input id="consent_performance" type="checkbox" /><label for="consent_performance">Performance Cookies</label>

<input id="consent_targeting" type="checkbox" /><label for="consent_targeting">Targeting Cookies</label>

<button type="button" class="button" id="consent_save">Save Settings</button>

Download The Google Tag Manager Recipe Here

I would then suggest taking a read of my Google Tag Manager - Bypass AdBlock Plus post, to make sure this doesn't get blocked.