in ,

How to use CAOS and Analytics with a Cookie Notice (GDPR)

Use Google Analytics with CAOS and a Cookie Notice

Since the 25th of May, our (online) lives have been blessed with a new and improved GDPR. You might’ve noticed my shiny new Cookie Notice! For novice users it raised a lot of questions. Because as a law-abiding citizen, what the hell do I have to do to keep a good, law-abiding website? If you’re a Google Analytics user, look no further. Today I’m going to show you how you can use CAOS (and all of its locally hosted analytics.js goodness!) to make your WordPress-blog GDPR-proof.

This tutorial covers one of the most used Cookie Notice-plugins for WordPress.

Since version 1.60 I’ve made some impactful changes to CAOS for Analytics to increase compatibility with other Cookie Notice WordPress-plugins. Since then, CAOS isn’t just compatible with the plugin mentioned in this post, but basically with all of them!

Are you using another Cookie Notice plugin for WordPress? You can still give CAOS for Analytics a try. Contact me, and I’ll help you set it up and I may even write up another tutorial!

First off, I have some good news. I know it’s been a while (!) but I recently released CAOS v. 1.50 to celebrate the coming of GDPR. Err, no. Not exactly. Let’s say I updated CAOS to allow you to keep using it in a GDPR complaint way.

So, before you continue. Make sure you’re using CAOS v. 1.50 or higher. Besides that, we’re going to call in the help of another nifty, little plugin called GDPR Cookie Consent to generate the Cookie Notice for you.

This is how it works: Basically, the plugin renders a Cookie Notice to any new visitors of your website. When a user clicks the ‘Approve’-button, a cookie is created. In turn, CAOS checks whether this cookie is present and renders its locally hosted Analytics-tracking script.

How to Configure CAOS to be GDPR Compliant

After following the steps below, your WordPress-blog will abide to the new laws enforced by the GDPR. Your Google Analytics-tracking scripts will still be locally hosted so you can have the best of both worlds. Follow the rules, and maintain your high score on Pingdom and Google Pagespeed. Let’s get started!

Enabling the Cookie Notice

How to Configure GDPR Cookie Consent with CAOS.
How to Configure GDPR Cookie Consent with CAOS.

The Cookie Notice will be provided by an external plugin, because I thought it was beyond the scope of my CAOS-plugin to build a Cookie Notice into it. I recommend using ‘GDPR Cookie Consent‘ by Webtoffee. It’s light-weight, easily configurable and fully tested and compatible with CAOS.

  1. Open the ‘Plugins‘ menu and click ‘Add new‘.
  2. In the next screen that opens, search for ‘GDPR Cookie Consent‘.
  3. The plugin will show at the top of the search results. Click ‘install now‘.
  4. After it’s finished downloading, click ‘activate‘.

A new menu-item will be added to your Administrator-menu, called ‘Cookie Law Info‘. Right underneath your ‘Comments‘-manager. Open it and you’ll see four options. ‘Cookie List‘, ‘Add new‘ and ‘Non-necessary Cookie‘ are beyond the scope of this post. So click on ‘Cookie Law Settings‘ to configure the cookie notice’s visuals and functioning.

Configuring CAOS and Google Analytics for GDPR Compliance

Configure CAOS to be Compatible with GDPR Cookie Notice
Configure CAOS to be Compatible with GDPR Cookie Notice

So now you’ll probably have a shiny new Cookie Notice on your WordPress-blog… Like mine! (We could be Cookie buddies! :D) Now all you need to is tell CAOS to check for the cookie created by Webtoffee’s plugin. Don’t worry, it’s as easy as cake… or Cookies!

  1. Open the ‘Settings‘-menu and click on ‘Optimize Analytics‘ to open CAOS’ configuration screen.
  2. Select the value ‘When cookie has a value‘ in the ‘Allow tracking…‘-section.
  3. In the field named ‘Cookie name‘ enter ‘viewed_cookie_policy‘. This is the name of the cookie generated by GDPR Cookie Consent once a user clicked the ‘Approve‘-button.
  4. In the field named ‘Cookie value‘ enter ‘yes‘. This is the value that is set to the cookie once the user clicks ‘Approve‘ in the Cookie Notice.
  5. Enter a value in the ‘Cookie expiry period‘-field. I use ‘30‘, since I don’t think I can keep following you around for more than a month. I get tired, you know…
  6. Press ‘Save Changes‘ and if you use any caching-plugins, make sure you flush your cache.

That’s it! You’re done. You’ve now configured CAOS and Google Analytics with a cookie notice to be fully compliant with GDPR. Enjoy!

Buy me a beer?

Do you appreciate my work and support? Please consider supporting me by donating, so I can continue to develop and write useful solutions for you.

Choose amount

Personal Message

Thank you! 🙂

Written by Daan van den Bergh

Magento 2 Back-end Developer with a passion for trainlifting, airplane-gliding, hunting trees and creating fake hobbies.

12 Comments

Leave a Reply
    • I’m not sure. I have no experience with Cookiebot. But you can check which cookie Cookiebot generates after you ‘Approve’ the usage of cookies, using your Inspector tools in your browser. I’ll check it out soon and get back to you, okay?

    • I’m sorry. I tried installing Cookiebot in a local environment, but since it needs registration it’s hard for me to test compatibility with CAOS. The only answer I can give you is: if ‘CookieConsent’ is the name of the cookie generated after the user gives consent to use cookies, then that should work!

  1. Hi Daan,
    CAOS is a great plugin and I use it on my webpage, thank you! But after the last update to 1.5 version it seems not working anymore. I tried to install ‘GDPR Cookie Consent‘ plugin, but this plugin also not working, it simply won’t create any cookie and nothing happens after pressing “Accept” button.

    • Hi Saulius,

      It was my fault! I’m sorry! There was a bug in my code that would cause CAOS to only work if GDPR was fully enabled. Please update to version 1.53 and everything should work fine. If local-ga.js becomes empty after the update, please de-activate and activate the plugin to trigger the cron. It should be fine then!

      Good luck!

  2. Hi Daan,

    I’ve configured the plugin CAOS as you describe, but I have a doubt.
    When Analytics start to work and collect data?:
    – After press the ‘accept’ button? or
    – After press the ‘accept’ button and reload web?

    Thanks for your time

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.