Saturday 04 February 2012

Filter Yourself From Google Analytics

iStock_000016132814XSmall

If you are like me, you are probably one of the most frequent visitors to your own site. And if you are using Google Analytics this can present a number of problems when it comes to accurate reporting. This tutorial explains the best and easiest way to filter your own computer from Analytics reporting.

This is a two pronged approach that uses a combination of scripting to place a cookie on your computer and a custom filter in Google Analytics.

STEP 1 – Cookie

The first thing that you need to do is create an HTML file that places the required cookie information on your computer. To do this you will need to create a blank HTML file. If you are not familiar with HTML, simply open a new text file in Windows (not a Word Pad file, rather a Note Pad file). Now save this file as filterGA.html and keep it open for editing.

You will need to place the following into the file and save it when finished:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Filter GA</title>
</head>
<body onLoad=”javascript:pageTracker._setVar(‘test_value’);”>
<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-927027-2″);
pageTracker._trackPageview();
</script>
</body>
</html>

Now upload this file (filterGA.html) to your web server. Place it anywhere you want as long as the file can be accessed from a web browser.

Next, visit the page that you just uploaded using your browser. You should see a blank white page. I recommend bookmarking this page so that you can re-visit the page anytime you are working on a new computer or after you clear your cookies and cache from your machine.

STEP 2 – Filter

Now, you will need to set up a filter in Google Analytics. Log into your Analytics account and navigate to the Filter Manager, then click the link to add a new filter.

In the first field add a name for the filter for identification.

In the second field, from the drop-down select “Custom Filter.” This will open additional fields. Select the radio button next to the top choice, “Exclude.”

From the drop-down menu called “Filter Field” select the option “User Defined.”

In the “Filter Pattern” field, type “test_value” and choose “no” for case sensitive.

Select the websites that you wish to apply the filter too (most likely all of the sites being tracked in your Analytics account), and save your changes.

Finished! You are now being filtered out of your analytics reporting from this moment onward. Just remember to re-visit the filterGA.html page from each computer that you use to view your traffic stats. Also be sure to revisit the cookie page if you delete cookies or clear your old browsing data to ensure that the cookie remains in place.

There are many ways to filter yourself out of Google Analytics, but this method is my preferred option. In this way I have more control over when and from where I am filtered.

About the author

Founder of Eos Designs and co-founder of iPrintEasy and a number of other web businesses - an entrepreneur with over 10 years of experience in Internet Marketing - Zach understands what it takes to be successful online and specializes in the development of advertising campaigns and marketing plans for start-ups.
  • Matt

    It seems like I had to put a cookie “test_value” on EVERY DOMAIN I’ve in analytics ’cause it doesn’t work for me now, as I’ve the cookie only on one domain. My traffic is excluded only there, on the others, no.

  • http://corythompson.net Cory Thompson

    Thanks Heaps..

    I was thinking my blog was getting a lot of hits. Now i can get accurate website stats..

    Thanks again

    Cory Thompson’s last blog post… How to install DOS into VirtualBox

  • http://glenmcniel.com ZenGlen

    We have to change the tracker ID right? (UA-XXXXXX-X)

  • http://tcladin.cz tcladin

    hi, i want use GA excluding with test_value cookie. I thing, every is right, but im not sure that excluding working.
    I try to answering by including test_values in GA. But no visits in this profile.
    In my browser (opera in Mandriva 2009) exist cookie __utmv:181981858.test_value
    Please help me, where is bug

  • http://www.freelancing-on-net.com freelance writer

    yes i am implementing it to my site right now… great article…

  • http://www.surveys4cash.com Vi

    Thanks Zach for instructions, as google help page doesn’t help so much.

  • http://jackrabbit.com/blog/ Alex @Jackrabbit.com

    Hi Zach.
    I just discovered his post and wanted to add a trick that might be helpful to your readers. Using the filter rules to filter all traffic from the IP address of your office might be good for businesses. That way employee traffic from the office isn't misinterpreted as real traffic. You can do this in profile settings.

    Recent blog post…Why I Ditched the Desktop & Switched to a Laptop to Help Me Run My Small Business

  • http://www.disabilitycounsel.net/ Disability Attorney

    I know this is an old post, but thanks! It's funny how skewed your analytics data becomes when Google is counting your own searches. This is especially a problem when you are trying to figure out which keyword searches are drawing real visitors to your site. Thanks for the help!

  • Jack

    I've followed the instructions but the question I have is how do I know it's working? I can't find anything on the GA site that says "hey this was filtered". Am I asking too much?

  • Rick Hollandsworth

    @ZenGlen @zachgraeve:twitter Zach, can you answer ZenGlen’s question about changing the tracking code please. Also, I have a client that has two tracking codes on two different sites, is there a way include a script on the HTML page that would exclude him from both sites or do I have to create 1 HTML file for both sites and have him visit them both separately? Thanks in advance! Great article… simple! (kind of)

  • GB

    Zach,

    Is there any place I can check in the browser’s cookies to make sure this particular test_value is set?  I am not super familiar with cookie technology but can look under the hood.

    Thanks!

Powered by WordPress | Privacy Policy | Web Design Miami