9 August 2015

Cookie Consent / IdiocyCookie Consent laws: you have surely seen them.

You go to a site, and you get a popup or bar at the top of the site that says, “We use cookies, blah blah blah…”

There is usually a “Learn more” link, and sometimes a way to accept or reject that site’s use of cookies.

The reason for this is a very stupid law implemented in the European Union that is supposed to protect people from… well, actually, it doesn’t protect anyone from anything. Okay, technically, it protects you from your sanity.

Especially if you use Google Adsense to put ads on your web site, you probably have received an e-mail from them telling you that you must have a Cookie Consent thingie on your site by the end of September 2015 in order to comply with yet another EU cookie law.

Right, so, how do you add cookie consent to your site – quickly and easily?

Piece of cake!

When you read Google’s e-mail to you, it contains a link to cookiechoices.org.

“Cool!” you think. “Surely Google will tell me exactly what to do!”

Family-feud-3-strikesOooh, I’m sorry! You’re wrong.

Or are you?

On the CookieChoices.org web site, which is Google’s site, you will find absolutely no useful information about HOW to actually implement cookie consent.

But, if you search Google for “cookiechoices.js” – in French – you’ll see this:

cookiechoices.js French Google searchAs you can see, the highlighted portion is a link to cookiechoices.org. The rest of the highlighted text says:

You should also download the file cookiechoices.js, then…

But if you go visit CookieChoices.org – in any language – you won’t find a link to this file. You can even try searching Google directly for this mysterious file (that Google created), and you still won’t have any luck.

Instead, just download cookiechoices.js here.

I discovered this file since it’s used in the WordPress plugin WF Cookie Consent. Obviously, if you’re using WP, just grab that plugin and you’re done.

For other non-WordPress sites, the easiest way to add cookie consent is through pure JavaScript. With just JS, you can add the popup box to every page on your site by simply including cookiechoices.js. It will set a cookie (through JavaScript) so that the notice doesn’t appear again after it’s displayed to your readers.

CookieChoices.js already includes translations for German, Italian, French, Dutch, Finnish, and English. You call it like this:

<scrìpt src="[PATH TO cookiechoices.js]"></scrìpt>
    linkHref: '[URL TO YOUR COOKIE POLICY]',
    language: 'en'

Replace the accented “i” in the SCRIPT tags with normal ones, of course…

That’s it. You can also modify the cookiechoices.js file to add more languages, change the color of the popup cookie consent bar, change the name of the cookie it will create, etc.

The magic of this solution is that you don’t have to modify your site/app at all. It’s pure JS.

The hilarity of the whole Cookie Consent thing is that, in order to consent to cookies, the cookie consent process will add yet another cookie to your browser.

Seriously, who dreams these things up?!

As to why Google has made this cookiechoices.js code that they wrote so hard to find? I have no idea. But given the insanity of the EU Cookie Laws anyway, I guess I shouldn’t be surprised.

Finally, keep in mind that cookies really aren’t a serious threat to anyone… at least, they are nowhere near the threat to privacy that browser fingerprints are!

Get Scottie Stuff!
How to add an EU Cookie Consent popup to your web site
Tagged on:             

11 thoughts on “How to add an EU Cookie Consent popup to your web site

  • 31 July 2018 at 21:25

    Homestead.com is my web host and has been for years. I’ve put off implementing this until I recently got a notification from Google Adsense, and thought I’d better figure out how this works before I get penalized. The thing I’m confused about is how I can use this with Homestead.com. It’s not a web site made from scratch(I wish), but I can upload files to the root, I can put html code in the head section in a special window provided for the web developer, or add the html to a defined area on the page itself. (on the back end) I’ve tried adding this code all 3 ways but it’s not working for me. Maybe it’s not showing the pop-up because I’ve visited the site before? I will be eternally grateful if you can help. I’ve been in circles reading blogs and articles and your’s is the first one that seems to have the correct js for this. Thanks in advance!

    • 31 July 2018 at 21:47

      D’OH!!! Typo in the article! There was an extra “)” in the JS code… 🙁

      So, it should work if you download the cookieschoices.zip file, and then extract the cookiechoices.js file and upload it to the web root folder.

      That should make your url: //www.survivallandusa.com/cookiechoices.js

      Then in the head section of your web site, add the JS code from the article, but with the following changes:

      linkHref: '//www.survivallandusa.com/cookiechoices.js',
      language: 'en'

      That should do it.

  • 31 July 2018 at 23:08

    Thanks a million for trying to help me! I uploaded the file to my computer, extracted it, and imported it to the root. Then I out the code you suggested into the code in the article, changed the slanted i’s to straight ones, and put them in the head section. Published the site. When I visit the home page I don’t see it. Would you mind checking?

    • 31 July 2018 at 23:46

      Oh, I see… For some reason, the JS is being included in a tag, which isn’t right.

      I’m not sure how to fix that, because I’ve never used this homestead hosting before…

  • 1 August 2018 at 06:09

    That’s okay, I appreciate your time! I think I found an alternative. Take care. 🙂

  • 12 November 2018 at 08:33

    Actually cookies can be to some degree, an issue pertinent to personal privacy. Cookies can be associated with a particular person–you, using such things as tracking pixels. You maybe buy something or fill out a contact us form or do a questionnaire or something, and a cookie with much more power in it than the typical cookie can be attached to your browser. Cookies still won’t be ‘damaging,’ but they can do more than the article implies in terms of finding things out about your browsing habits, etc.

    • 5 February 2020 at 13:11

      You can’t include the JS as a hyperlink. You have to either include it inside the <HEAD>…</HEAD> tags of the web page, or just before the closing </BODY> tag.

      • 6 February 2020 at 20:07

        ah that didn’t show up right. It’s under my Head tag, like this:

        linkHref: ‘//paperstest2020.metropublisher.net/privacy-policy’,
        language: ‘en’

        This should work, right?

  • 6 February 2020 at 20:11

    Sorry, it’s eating up the script tags even if I copy them from your article with the accented i’s.

    it’s [script src=”/downloads/218/download/cookiechoices.js”] close script, before the cookieChoices script.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.