Friday 31 July 2015

How to create a cookie notification for countries in the EU

Sites that use cookies must present a notice about cookies to users from the European Union (EU). Seeing the notice, users should be able to do one or more of the following:

  • Agree and use the site
  • Learn more on what cookies are being used
  • Optionally be able to block these cookies.

If you use the Blogger platform and use cookies only from Google


Google can display the following notice without you having to do anything:
This site uses cookies from Google to deliver its services, and to analyse traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies.

All other sites


  • Modify Google's message, link to a landing page on your site which has links to privacy policies of all entities whose cookies you use. This blog uses this approach. See [2].
  • Forego Google's notice entirely and instead use one of the tools suggested by Google in [1] e.g.  Cookie Consent by SilkTide. You will also have to detect the country of the user.

Testing


  • If you use are on blogger, use a domain that belongs to a country from EU e.g. yaanqing.blogspot.fr (France).
  • If you are on blogger but use a custom domain, see this blog on how to test. Basically, append "prx.gb.teleport.to" without quotes to the domain e.g. custom-blogger-domain.com.prx.gb.teleport.to

Going further


If you stop after doing the above, the user can continue to use the site. However, if you would like to go further, you can also allow the user to block the cookies and still be able to use the site. This has may be done by using a cookie (or a local database) whose only purpose is to say which cookies the user wants! The site's code would then inspect this cookie before using code that creates any cookie.

Reference

  1. Google has a page that explains the above in detail.
  2. The following code links to the Privacy page in this blog. The code and the page are the only things that need to be done.

<!-- code to be inserted just before the end tag for HEAD -->
<script type='text/javascript'>
  cookieOptions = {
    msg: &quot;This site uses cookies from Google to deliver its services, and to analyse traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies.&quot;,
    link: &quot;http://yaanqing.blogspot.com/p/privacy.html&quot;,
    close: &quot;Got it!&quot;,
    learn: &quot;Learn more&quot;
  };
</script>

No comments:

Post a Comment

Popular posts