Disable Google Analytics


If you would ask me what is the best Google Analytics resource, I would’nt think twice before sending you here. However, for the problem we had we found something different. I’m using Google analytics quite a lot on every site I work on. Recently we had a problem at one of my customers sites, where the marketing people working in that company were browsing their website all day, searching in Google their website keywords again and again, and made Google Analytics reports become unreliable. There were so many visits in the reports that were not real customers but our own staff, that we didn’t really know which part of the report was real and which part was our own tracks.

Like in every crime scene, we just needed our guys to put on gloves before touching everything…

The solution was very simple.

1. We created a file called disable_analytcis.php

<?php
SetCookie(“disable_analytics”,”1″ ,time()+91536000,”/”);
echo “Yuhu!, Google analytics is disabled!”;
?>

2. In the site footer, next to the Google analytics code, we added this:

<?
if (!empty($_COOKIE['disable_analytics']))
{
echo “Google analytics is disabled”;
}
else
{
?>
//put google analytics code here…
<?
}
?>

That was easy. The hard part was to send the link to disable_analytics.php to all the sales and marketing in that company and ask them to click on the link. They ALL wanted to know exactly WTF is going on here… are we spying on them? yes? no? what do you mean Google keeps track??? anonymous? who authorized this… :)

Once everybody got their cookie, our statistics cleared up. Real client analytics emerged and logs turned useful again. When you do it on your site, make sure your cookie gets to all computers, home computers, laptops and any computer that you don’t want to track.

update: (Thanks Pieter!)
Google offers cookie based filters, as described in Google Analytics Help Center:
Create an Exclude filter to remove data from visitors with this cookie. Follow these instructions to create a filter with the following settings:
Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: disable_analytics
Case Sensitive: No

This entry was posted in google analytics, web development. Bookmark the permalink.

11 Responses to Disable Google Analytics

  1. Pieter says:

    As far as I know, Google actually encourage you to set up ‘Filters’ to exclude certain users, departments, etc. See http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55481

  2. yair says:

    Hi Pieter,
    You’re right!.
    Google suggests to add a separate page that creates the cookie, the same as I did. (They do it with javascript, I do it with PHP)
    The option I didn’t know is cookie based filters.
    I actually like it better, it is less code changes on site.
    I will update my post with this info.
    Thanks!

  3. Al says:

    this post was very helpfull.
    It is actually simpler then I thouht.
    I was actually trying to disable google analytics by blocking their script through adblock but this looks much easier to my team.
    Thanks!

  4. CMS says:

    My clients are running on windows servers, do you have code other then the PHP?

    Many thanks,
    CMS

  5. Sam says:

    How do I, as a browser of a site with Google Analytics, turn it off or disable it. I do not want my browsing habits tracked, traced, recorded or used by anybody, any business or any conglomerate to try to force feed more advertising down my throat. Or is this yet another example we can expect from Google in their quest to quash all hints of privacy in American life?

  6. Chris says:

    One Suggestion is to download and run Mozilla Firefox, the latest edition and apply every possible security extension that you can get. Some of my favorites are Ghostery, No-Script, free adblock plus, flashblock, yet I am still looking for a PHP and Java blocker. You might want to consider a proxy as well. Hey these guys are hacking us… Now, we must begin to think like hackers to track and remove their tracking bugs.

    This is the only way to bypass Google Analytics safely. Also remember to clear your personal information and super-cookies.

  7. Laura says:

    hi chris – i am trying to disable google analytics as i do not want to be tracked – i have firefox on my mac and have dowloaded the add-ons you have suggested above – is there any others that you might suggest? do they disable google analytics totally? thanks in advance for your help!

  8. ket says:

    How can I disable google-analytic on my wordpress web site. It does not let me do anything on the admin control panel. It refreshes anytime I click a link and loads blank page for—maybe–eternity.

    This is very annoyed me.

    Thanks

  9. Dinesh Prasad says:

    google analytics is the most overrated piece of garbage web analytics package for the simply reason its SLOW AS HELL. WHATS WRONG GOOGLE I THOUGHT YOU WERE THE BEST AND BRIGHTEST?? take some time to peel youe eyeballs from your stock price and add some bandwidth. it’s been slower than a snail for over a week, what a bunch of wannabe’s google needs to stick to its core competencies.

  10. Pingback: Disable Google Analytics | hot cool news

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>