Filtering Yourself Out of Google Analytics

As you make changes and test different things on your site, you and the people you work with will inevitably wind up visiting your own site.
A lot.
And that means Google Analytics is count you along with the rest of your users. Not a big deal if you have thousands and thousands of visitors (though it’s still not ideal), but it sucks if you are just starting out.
Your browsing is going to skew the precious data that you want to use to make better decisions about your site. You want your data to be accurate.
The solution? You must filter yourself out of Google Analytics.
There are two common ways to do it:
- By IP address
- Via a cookie
I’m going to focus on the one I think is most useful to all of you: the cookie method. Cookies are simply tiny files that are used to convey information to your web browser.
What I will walk you through in this post is how to set up a cookie that allows your website to identify you and not count you in the Google Analytics data.
Step One: Setting the Cookie
Here is what you need to do:
Create a new page on your site
This is pretty easy. Just go to an existing page, right click on it and hit “View Source.” Copy all this code and paste it into Notepad (or better yet, Notepad++), then save this as a new HTML file. Done.
Make sure it has Google Analytics code on it just like all the other pages
If you used the method I just described, the code should be on there, but make sure to double check. Oh and please use the new asynchronous code…otherwise this won’t work right.
Add one line of code to it
Look for these two lines of Google Analytics code on your page:
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
Now just add this new line of code:
_gaq.push(['_setVar','pickaname']);
Where pickaname is something you pick. This is what it should look like after you’re done:
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setVar','boomgoesthedynamite']);
_gaq.push(['_trackPageview']);
Upload to your server
Use whatever FTP client you want to push this new file onto your server.
Visit the page
If the file you saved in the first step was called “monkeytime.html” then you should go to yourdomain.com/monkeytime.html. You should see the page you created in step one.
Visiting the page will set the cookie on your computer—you should visit this page from any computer you want to block from the Analytics report.
If you want to double check that it worked, check your cookies in your browser and in your domain—you should see one called _utmv. Click on it and you should see the unique name you gave it (boomgoesthedynamite) in the information for that cookie.
Step Two: Creating a Filter in Google Analytics
Now that you’ve set the cookie, we have to tell Google Analytics to look for it and to throw out any visits from people with that cookie on their machines. Go to the Edit section of the profile you want to create a filter for:

Then click on the Add Filter button:

Enter the following information into the filter:
- Add new Filter for Profile
- Give your filter a name (be descriptive!)
- Filter Type: Exclude
- Filter Field: User Defined
- Filter Pattern: Enter the unique name you added to the code in Step One (boomgoesthedynamite)

That’s it! Testing this is tricky, but if you can find a page on your site that gets zero traffic (like maybe the cookie page you just created…) and visit it repeatedly, you should be able to figure out if you’re being counted or not.
If you’ll be blocking a lot of people (co-workers, etc.) using this method, make sure you tell Analytics to not count that cookie page either. It’s not a big deal and it shouldn’t impact your reports that much, but if you want to be precise you should go ahead and block it with a filter that looks like this:

Image by Gabe Photos
















