Disable Google Analytics Tracking

Many people doesn’t  like to be tracked from Google Analytics. For privacy purposes you have to enable your site vitors with one click to be able to deactivate  or disable google analytics tracking.   There are many ways for an experienced users to do this:

  • Disable Java Script or using Add-ons from the Browser , but actuall it is not possible to navigate throw a website without activating javaScript, due to animations and ajax requests.
  • The second way is do not accept cookies from the website. Google analytics tracking is based on cookies,  your google analytics is usingga() or the pixel tracking function _gaq.push().

The third solution is mandatory , if you have binding  google analytics tracking in your website.

Here is the code that you have to add in the imprint or privacy page:

<a href=”javascript:gaOptout()”>Disable Google Analytics</a>

In the <head> section add your google analytics code followed by the gaOptout() function.

<script type="text/javascript">
var gaProperty = 'UA-XXXXXXXX-XX';
	var disableStr = 'ga-disable-' + gaProperty;
	if (document.cookie.indexOf(disableStr + '=true') > -1) {
	  window[disableStr] = true;
	function gaOptout() {
	  document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
	  window[disableStr] = true;
	  alert('Google Analytics was deactivated.');

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');


The user will be able now to disable or stogpping google analytics tracking until the next cookies was deleted.

You are using also the anonymizeIp function. Using this function is also a mandatory to protect the user privacy.
The result can you see using Firebug Add-ons in the Firefox browser or something similar:
Disable Google Analytics

For more information about google analytics privacy can you find  more information here: GOOGLE ANALYTICS TERMS OF SERVICE

Demo on this site:
Disable Google Analytics