The quickest way on the road to become GDPR compliant – disabling google analytics with one JavaScript line

Well, I’m not going to write the full guide to GDPR compliance yet, but pay attention to this mind blowing discovery:

Google provides a way to disable analytics, so it doesn’t save cookies or sends any data remotely, simply by adding one line of JavaScript code:

Of course replace “UA-xxxxxxx-x” with your analytics ID of the property that you would like to disable.
The benefit of disabling Google Analytics this way is by keeping the ga object so all embedded analytics events do not trigger a JavaScript error!

If you implement analytics in an application or in a legacy mode find the appropriate code for you here.

I would love hearing your comments on this and how you implemented GDPR compliance chez vous.

One comment

  1. and if you need to enable Google analytics again (after the visitor accepted the cookies policy) just use:
    window[‘ga-disable-UA-2078566-1’] = false;
    and then send an event for the current pageview:
    ga(‘send’, ‘pageview’, location.pathname);

Leave a Reply

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