Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Have you ever wondered why some sites display a cookie consent notice? If you or your business is located in the European Union, or if you are targeting EU citizens AND you’re using tracking software (i.e. Google Analytics), then you need to display a cookie consent notification on your website. In this Google Tag Manager Cookie Consent guide, I’ll show you how to install one without much hassle.

 

Short context

In May 2011, a European Union (EU) Directive was adopted by all EU member countries to protect consumer privacy online. This piece of privacy legislation requires that covered websites:

  • Let users know if they are using cookies.
  • Explain what data is gathered through the use of cookies and how that data is used.
  • Gather user consent to the use of cookies.

cookie consent

The law is enforced by governing bodies in the EU, and therefore cannot apply unilaterally to everyone. If you live outside of the EU, have a website hosted on a server outside of the EU, and are targeting consumers anywhere other than the EU, you don’t need a cookie consent notice.

But since it’s pretty difficult to avoid visitors from European Union, you should add a consent notification.

 

So What’s The Plan?

For the notification to work, you’ll need to complete the following steps:

  • Get a Javascript code of Cookie Consent Notification. It displays a message to your visitor and once he/she clicks Got It button, saves a cookie in visitor’s browser. The cookie makes sure that a person does not see the notification on every page load. If a visitor uses different browser or clears browser cache/cookies, the notification will be displayed once again.
  • Modify the code in order to match notification’s style with your website’s. In addition to that, you’ll need to edit text as well.
  • Create a Privacy Policy page and paste its link to notification’s Javascript code.
  • Publish Javascript code with help of Google Tag Manager.
  • Test, test, test.

 

Cookie Consent Code

For your convenience, I have created a ready-made Google Tag Manager Cookie Consent Recipe. Just download it, import it to your GTM container and follow the instructions.

If you’re willing to better understand how everything works, continue reading.

For Cookie Consent Javascript code, I chose a free solution offered by Insites (which you have already seen on my website). They offer a user-friendly solution with configuration wizard. You can choose notification’s position, layout, color theme, edit content, etc.

Insites cookie consent setup wizard

After you finish configuring your cookie consent notice, on the right side of the screen, you’ll see a read-to-use code. It should look like this:

If you use my Google Tag Manager Cookie Consent Recipe, then this code is already created as a Custom HTML tag. In that case, do not forget to edit the following parameters in the code:

  • background and text colors (to match the style of your brand).
  • message (this is the main text of the notification).
  • dismiss (title of the main button).
  • link (“Privacy Policy” link title).
  • href (actual link to your “Privacy Policy” page. I have explained how to create a PP page in the next chapter of this blog post.).

Great! The code is complete. Now, you should take care of Privacy Policy page.

 

How to create a Privacy Policy page

In this chapter we’ll need to find a quick solution how we can easily create this page without help of lawyers whose services are pretty expensive 🙂

My recommendation for you: don’t try to invent the wheel, it’s already been created. Use others’ creations and adapt them to your needs.

There are two quick ways to get a Privacy Policy:

  • Use a Privacy Policy generator.
  • Take a look what well-known players in your industry (or competitors) are using.

 

Privacy Policy Generator

Here are several alternatives to choose from:

  • Getterms.io – generates 2-in-1: Terms of Use and Privacy policy.
    • Pros – easy to generate and free.
    • Cons – a bit too broad, does not cover various nuances and isn’t personalized.
  • Termsfeed – Generates a Privacy Policy, adapted to your business.
    • Pros – easy to generate, personalized.
    • Cons – isn’t free, price depends on your needs and technologies you use.
  • SerpRank Generator (requires free account) + Freeprivacypolicy.com. For Analytics Mania, I just took these two resources and used their best/most suitable parts.
    • Pros – free.
    • Cons – requires a bit more effort while editing the content.

 

“Borrow” ideas from Well Known Websites/Competitors

Several reasons to choose this method:

  • Owners of well-known website (usually) invest in such content. They have probably consulted with lawyers to create it.
  • If you find a leader in your industry (or a pretty similar competitor) who has implemented Cookie Consent Notification on their website, that’s event better! They have prepared a ready-made template which should apply to your business as well.
  • Well, it’s free. While I am not encouraging you to 100% steal their policy, you can take it as a solid draft and easily edit it + cut unnecessary parts.

I will not explain Privacy Policies in detail, because I am not an expert in this field. If you wish to learn more, here are two resources for a good start – 7 steps to writing a good privacy policy and How do you create a privacy policy without spending a lot of money on lawyers? (Quora).

 

Set Up COOKIE CONSENT CODE With Google TAg Manager

For this part you’ll need to complete the following steps:

  • Create a trigger – Page view or DOM ready. In my Google Tag Manager Cookie Consent Recipe, I used DOM ready. I tried to utilize Window Loaded trigger, but it did not work. So save your time and just use one of two aforementioned options.
  • Create a Custom HTML tag and paste our modified Cookie Consent Javascript code and link it with DOM Ready trigger.
  • Test and publish.

 

Create a trigger

In your Google Tag Manager account, go to Triggers and create new one with the following settings:

Pageview - DOM ready

 

CREATE A TAG

Now, let’s head over to Tags and create a Custom HTML tag which will contain code of cookie notification. Its settings should look like this:

Google Tag Manager Cookie Consent - custom HTML tag

cHTML (in the title) stands for Custom HTML. If you wish to learn more about naming conventions in Google Tag Manager, read this awesome blog post by Lunametrics.

If you skipped some chapters of this blog post, make sure you have edited the following settings in the Javascript of cookie consent notification:

  • background and text (to match colors of your site).
    color codes
  • message (this is the main text of the notification).
  • dismiss (title of the main button).
  • link (“Privacy Policy” link title).
  • href (actual link to your “Privacy Policy” page).

 

Time To Test

Use Google Tag Manager’s Preview and Debug mode to test whether the notification appears when it’s supposed to. Click “Got It” button in the cookie consent dialog and refresh the page. If it did not reappear, you’re good to go!

If you’re new to GTM, here’s a comprehensive guide to Preview and Debug mode. It’s an essential tool in tag deployment process, so make sure you fully understand its capabilities.

 

Google Tag Manager Cookie Consent: Conclusion

If your website visitors are from the European Union or your business/website is located in the EU, you must display a cookie consent notification which informs visitors that you’re using cookies.

In this blog post, I explained how you can easily generate a Javascript code of cookie notification and implement it with help of Google Tag Manager.

I am using that very same solution on analyticsmania.com as well. If you don’t like its style, head over to Cookie Consent by Insites and generate your own code.

For your convenience, I have created a ready made Google Tag Manager Cookie Consent Recipe. Just download it, follow the instructions and publish on your website.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Julius Fedorovicius

Product manager at Soundest. I am highly interested in Google Tag Manager, Google Analytics, Adwords, Email marketing, Email Deliverability, Digital Marketing in general. You can follow me on Twitter.