Count Me Out!

To keep your Google Analytics data pure you should remove all traffic generated by yourself or others that may not be real visitors. For example, if your company has a large call center you should remove the traffic they generate because it will skew your analytics data.

To remove this data we usually use an exclude filter based on IP address, host name or geographic location. While this is effective the results can be a bit ‘broad’. What I mean is you may not want to remove ALL of the traffic from an IP address, host name or geographic location.

Here’s another example. I have a blog (obviously) that I track with Google Analytics and I want to remove all of the traffic I generate. I don’t want to use an exclude filter based on IP address or geographic location because I want to see traffic generated by others in my company and city/state. I only want to exclude the traffic from the computer I am working on.

This technique can also be used if you have a dynamic IP address.

The solution is to create an exclude filter based on another piece of data, more specifically a custom segment. This method isn’t as broad as an exclude filter based on IP, hostname or geographic location. The filter is based on a cookie, which is specific to a computer. Using this method I can eliminate all of the traffic from an individual computer without affecting data created by others.

How to Set it Up

The first step is to set a cookie on your machine that will identify you to Google Analytics. We’re going to use GA’s custom segmentation functionality to do the.

I created a script that will set the GA custom segment cookie on your computer. You can view the source here.

Copy the source and paste it into your favorite editor. Then save the file. For the page to properly display on your website you will need to save it with the correct extension. You should be able to use a .html or .htm extension. It depends on your web server.

Once the file has been saved, upload it to your web server. You may need to use FTP. If you don’t know how to put the file on your web server consult with your web master. You can place the file anywhere on the site.

Then open a browser and type the location of the file in the browser. The page should display as an HTML form. If it displays as text then you probably need to change the file extension.

Enter some text into the text box and click the ‘Create Cookie’ button. The script will set the GA custom segment cookie on your computer and the cookie will have a value of whatever you entered into the text box. Do not use any white spaces or special characters when entering a value for your custom segment. Keep it simple, something like ‘exclude-me’ will work just fine. You should see a confirmation message that the cookie was set correctly.

The next step is to log into your GA account and create an exclude filter based on the value of the custom segment cookie. If you entered ‘exclude_me’ in the form then use ‘exclude_me’ as the value in the filter pattern field. Here are the settings for the exclude filter:

Filter to exclude user defined cookie.

This script works by taking the value you enter in the form and setting it as a custom segment. The great thing about this script is you can place it on your site and then access it from all the computers you work on. Just point a browser to the script, submit the form and all traffic from that machine will be excluded.

Keep in mind that the GA cookies are specific to a domain. So if you want to use this script for multiple websites you need to follow the above process for each domain.

The script is written in JavaScript and has been testing in FireFox 1.5 and IE 6.X.

Like this post? Share it:


And how about checking out these related posts:

  1. How Google Analytics Tracks Third-Party Domains
  2. Creating Test Profiles in Google Analytics

Comments

  1. Steve Plante says:

    Thank you for that excellent (and simple) tool for excluding internal traffic from GA data. I set up the page early this morning and put the cookie on 2 computers. Several tests have shown the traffic from those computers are being excluded. Previously I used exclusion by IP address, but these are changed by our ISP routinely (but randomly and with no notice), so excluding traffic this way was unreliable and a chore to maintain. I did also place our GA tracking code on this “Count Me Out” page. Thanks again for this solution.

  2. Eric says:

    Hey Justin,

    Thanks for this tool. It seems that this is a safer and more accurate way to exclude yourself if your on a High-Speed connection with a dynamic IP that will change eventually.

    I appreciate it!

    eric

  3. mary says:

    Justin,
    This is a great script.I wondered how I would maintain my
    filter as my ip addy is dynamically assigned.
    Thankyou

  4. Amanda says:

    Thanks a million times over. I was trying to block my hits by IP, and of course, mine is one of the magically changing IPs, so my hits would end up in the mix as well every now and again. Thanks for giving us a proper way to handle this problem.

  5. LewCipher says:

    Thanks for the script — how do you “unset” the segment value? Just delete/expire the cookie?

  6. Justin says:

    Hey LewCipher,

    Correct, to delete or ‘unset’ a segment simply delete or expire the cookie.

    Justin

  7. Robbin Steif says:

    Even though I user tested it with you that day and blogged about it, I still go back to this over and over again when I need to use it (like today) and teach my customers how to use it.

    Robbin

  8. Mark M says:

    Justin,
    Thanks for your help with this. I recently found another way to set the same kind of cookie.

    ************************************************
    Setting the cookie:

    Create a new page on your domain, containing the following code:

    <body onLoad=”javascript:__utmSetVar(‘no_report’)”>

    To prevent the page from being included in search indexes, you can also add the following in the head section:

    <meta name=”robots” content=”noindex, nofollow”>

    Visit this page from all computers that you would like to exclude from your reports, to set the cookie on each machine.

    Creating the filter:

    You’ll need to create an Exclude filter to remove data from visitors with this cookie. Follow the instructions at

    http://www.google.com/support/analytics/bin/answer.py?answer=27207

    to create a filter with the following settings:

    Filter Type: Custom filter > Exclude
    Filter Field: User Defined
    Filter Pattern: no_report
    Case Sensitive: No

    ************************************************

    This information comes from -
    http://groups.google.com/group/analytics-help-tracking/ (on this page, do a search for “Dynamic DNS Filter”)

    Mark M

  9. Terence S. says:

    Hey found this by searching on google! Great idea. This will help me out on both my sites. I really appreciate it.

    http://www.scubamazing.com
    http://www.terencechad.net

    ~The Scuba Skipper

  10. GolfBot says:

    Hi,

    this is an awesome solution. The GA Help Desk only sent me links to the help pages, and couldn’t help at all in solving the problem of dynamically assigned IPs. Thank god Google Search did a better job and pointed me right away to your blog entry.

    Well done, keep up the great work,

    GolfBot (Webmaster)
    Innenarchitektin Constanze Schuchmann

  11. Rob says:

    So Justin,

    If I use this script on my computer and then periodically delete and clean out all cookies then I will then have to re-run the script? Is this correct?

    Thanks!!

  12. Justin says:

    Hey Rob,

    Correct. If you delete your cookies from time to time then you will need to re-run the above process to re-create the cookie.

    Justin

  13. Richard says:

    Thanks for the code. This will help out a lot in keeping my GA data correct for my site: http://www.tacticalhuntingandcamping.com

  14. Johnny says:

    Hi Justin,

    I have a blogger.com account and am using the google analytics software on it. Unfortunately, there is no way that I know of to push a .html file up through the blogger.com interface and publish a separate private page for the purposes of this cookie creation script. Is there any way this script can be modified so that it can be run from a home users desktop and have the cookie created? Perhaps with an input field on the domain name the cookie should work under?

    I’m one of those that has a dynamic DHCP address, but I haven’t been able to use this solution because I can’t get this code to a private page on my blog.

    I could of course, add the cookie creation code to the main public page, hit it myself, then remove it right away but obviously this is not a good solution.

    Any feedback would be appreciated (please copy me in an email too if possible)

    Thanks,

    Johnny

  15. Justin says:

    Johnny,

    The script can’t use a form field for domain because it will violate the browser privacy policy. Cookies can only be set for the domain that you are currently on.

    What you might want to do is manually edit your cookies using notepad or a cookie editor (there are a few plug-ins for FireFox) to change the domain.

    Good Luck,

    Justin

  16. Thanks for the excellent tip !

    K

  17. Mike says:

    Here’s a couple of extra ideas for this.

    I’ll be making a couple of assumptions – firstly that you have access to the code the site is written in, secondly that your site uses a footer or template common to all pages.

    Many more advanced routers (such as the better ones provided by Netgear) provide dynamic dns facilities:
    http://kbserver.netgear.com/kb_web_files/n101279.asp

    This, in combination with some server-side scripting, will allow you to not print out the javascript when anyone accesses your site through your router:

    _uacct = “UA-111111-1″;
    urchinTracker();

    Or something like that.

    Another idea if you don’t have dynamic dns and use Firefox, is to define an extra useragent string using the about:config page in Firefox. Create a new preference name of something like general.useragent.extra.filter and give it a value of “analytics”.

    You can then use php/asp in a similar way to before to filter out your traffic.

  18. Mike says:

    Ah, the site has filtered out my code. In php your code will be similar to:

    if(($_SERVER['REMOTE_ADDR'])!=gethostbyname(‘example.dyndns.org’)) {
    Analytics code goes here!
    }

  19. technut says:

    If you only need to set the cookie on a couple of machines, then here’s a way to do it without creating a custom webpage.

    Browse to one of the web pages on your site that has your Google Analytics tracking code embedded.

    While at that page, copy/paste this code snippet into the browser address bar…

    javascript:__utmSetVar(‘no_report’)

    Hit Enter to execute that line and the cookie will now be set in the browser of that machine.

    Hope that saves someone a bit of time.

  20. Wow! I’m impressed with all of the different solutions to eliminating Google Analytics local traffic from reports. I have a solution to add as well.

    Originally, I considered using a cookie, but wasn’t sure how to implement it. I also considered attempting to use a Greasemonkey User Script to remove tha analytics. Instead, I created a wrapper function around the Google Analytics urchinTracker method. My wrapper checks for a parameter in the url. If the url is found, then the urchinTracker is not activated.

    This was especially helpful for eliminating the tracking on downloads, where the onclick event contains an entry with a string passed in as the key for the item.

    In addition, if the parameter was found in the url, I also have a function that gets all anchor tags and adds the parameter to each url. So once I disable the tracking, it takes effect on all pages until I remove that parameter from the url.

    Finally, if the parameter is found, I insert a notification at the top of my site that notifies me that the tracking is disabled!

    I like the cookie idea, as well as the separate page to access to activate the cookie. I may even try it myself, but I definitely had fun implementing my solution.

  21. neha says:

    hi,

    i have a public facing website. i have to exclude all the internal hits generated by the employees from my firm in google analytics and only take those into account which are generated from external users. i have tried using a range of ip addresses in my filter but it doesnt seem to work. i cant use the name of the dns. also, i m not sure if the solution with cookie that you have specified will work. since i ‘ve to exclude the whole of traffic generated by my firm not just one odd pc. Please let me know if you know of a solution. Thanks.

  22. Justin says:

    Ho Neha,

    If your company has a static IP address, then you can use the pre-defined filter in GA to exclude all traffic from an IP. If your org has multiple IP addresses then you’ll need to get cretive with the regular expression you use to define the IP address. This approach should work. Make sure your regular expression is correct.

    However, if your company has a dynamic IP address, then you should think about using the method I describe above.

    Hope that helps.

    Justin

  23. Debbie says:

    Thanks! What a great tip – this is something I can put on all of my clients’ sites and show them how to use.

  24. JP says:

    How do I get rid of a hostname that should not be in my list of hostnames?

  25. Justin says:

    Debbie,

    You can add an exclude filter to the profile to exclude any unwanted traffic from a hostname.

    Justin

  26. thanks for the GREAT post! Very useful…

  27. trigger says:

    Hello! thanks for the great tips and tricks. great reading.

    question….

    I have a members area and I’d like to segment the traffic in GA. That way I can see what members are viewing on the corp site. The cookie way looks like a great ‘tweak’ but i have concerns.

    Our login page has heavy traffic (imho). Maybe 6 to 10 logins per second on heavy days/hours.

    We keep our login page lite with minimal code as to not create any delays/issues etc for members logging in.

    Your idea is to add the ‘create’ cookie code on the successful login page, but our tech department says they CANT add that much code/javascript to the login page. They fear it will cause delays/errors etc.

    They say they’ll create any cookies needed, but not using the urchin.js file.

    Is there a way to set the __utmSetVar variable without actually calling the “__urchin.gif” from google?

    I don’t need any “Members Area” stats, i’m only trying to see what members/non members are viewing on the “Corp” site.

    Hopefully that made sense?
    thanks for your time.

  28. Hey Trigger,

    Trying to manually create the cookie is tough. What I would do is to try and use link tagging to isolate members. That way you’ll only need to change the login page URL (add the link tagging variables utm_campaign, utm_medium and utm_source). The downside of this approach is that if you want to track referral information you won’t be able to.

    Hope that helps,

    Justin

  29. Josh says:

    Thanks a lot everyone for the information and help. This has all been very useful and I can definitely use it on our http://www.meritsolutions.com site. Thank you thank you thank you.

  30. Vladimir says:

    Hi Justin,

    I recently bought your e-book. I hoped to find an answer on this problem.
    I’m trying to exclude traffic coming from a domain with a hyphen in it: abc-xyz.com. I used a custom exclude filter (hostname) to exclude the traffic form this domain: abc\-xyz
    But apparently this isn’t working.

    I tried several filters (standard exclude traffic from domain) and several settings like www\.abc\-xyz\.com and abc\-xyz\.com but nothing really works. These sites keep referring visitors in my stats.

    Can someone please help me out on this one?

  31. Hi Vladimir,

    Thanks for buying the book.

    Are you trying to eliminate the referrals from a specific domain? In that case you need to filter on a different field. Try the campaign medium.

    Or does your tracking code appear on abc-xyz.com and you’re trying to eliminate all traffic that is occurring on that domain? If this is the case the filter you have should work.

    Hope that helps,

    Justin

  32. Vladimir says:

    Hi Justin,

    I tried what you proposed (exclude campaign medium) but without results.

    The situation is as follows. The first domain http://www.abc-xyz.com keeps sending people to my site http://www.xyz.com. The first domain is a site that is used by colleagues. I want to exclude every visitor from http://www.abc-xyz.com in the stats of http://www.xyz.com, because it’s sort of internal traffic skewing my stats.

    I’ve tried about everything, so I guess I must have missed something. But what?

  33. Vladimir,

    The name of the referring website is stored in the campaign source filter field, not the campaign medium filter field.

    Justin

  34. emile says:

    Thank you so much for this! Much better than trying to decipher Google Analytics Help Center’s vague description.

  35. judy says:

    Thank you so much for this. You made it super easy :-)

  36. ATOzTOA says:

    Johhny,

    If you are using blogger…

    You can add a new Page Element -> HTML/Javascript.

    Put the above code in the element. Add the cookie. You are done. You can remove the page element with ease.

  37. Chris says:

    Thank you so much, it works at last! I’d been trying for hours to do this and then got it to work with your script. Great job!

  38. Great post, great tool, many thanks!

  39. SG says:

    Great post. My ISP assigns addresses via DHCP, and removing myself from Analytics’ stats will be very helpful.

  40. Anja says:

    Hey this was great! Now I can exclude all the right people just by giving them a few instructions over the phone. Cheers! Anja

  41. Rich says:

    Thanks for the tip!!!! very clear and easy to follow instructions

  42. Phil says:

    Hi Justin,
    Thanks for your help! I implemented a simple exclude filter with a cookie, but I’m not sure how to make sure it’s working. What’s the best way to check if the cookie & filter combo is working (ie, make sure my own traffic is not being counted)?
    Thanks a bunch,
    Phil

  43. Yael says:

    I have created the cookie for my machine but how do I delete the cookie from my machine? Thanks

  44. Hi Phil,

    I suggest you create multiple profiles in your GA account including a master profile that has ALL data, including your own. Then create a separate profile that excludes your data. You might also want to create test profile to experiment with new settings.

    Yael, if you want to delete the cookie just use your browser’s feature for deleting cookies. It’s different from one browser to another, but they all have some type of ‘delete cookie’ functionality.

    Thanks for reading and I hope that helps,

    Justin

  45. Agnes says:

    That looks absolutely awfully great, but I wonder: is it still valid for the GA “new code”? This “urchin” seems to me the old one… Any update?
    Thanks
    Agnes

  46. Hi Agnes,

    Unfortunately this only works with the urchin.js code. I’m trying to write another version for the ga.js code.

    Thanks for reading the blog,

    Justin

  47. MACC says:

    Thank you very much for your help!

  48. Tony says:

    Dear Justin,

    I am creating my own blog at blogspot, and use GA to measure traffic. I use regular ATT DSL connection from home. I use both Firefox and IE.

    I’d like to exclude myself from GA, but am having a hard time to understand your instructions.

    I copy-pasted the script on my notepad. From that onwards I don’t know what to do in order to reconfigure my cookie, and then set up the filter at GA.

    I’d be very grateful if you could help me with more pedestrian step-by-step instructions.

    Thank you for you care. And congratulations on your work and popularity!

    Tony

  49. Techmale says:

    Hi Justin
    We have been hitting the same problem. Our analytics data has been seriously distorted by our constant presence on the site, as we are constantly editing and administrating it.
    Your solution inspired me… to create an easy bookmarklet to add the exclusion cookie.
    Well, I hope it is easy. It does make it simple to implement, and everyone working on the site can use it.
    You can find it on http://www.techmale.com.
    I hope it helps.
    Cheers
    Ross

  50. Hi Tony,

    Unfortunately you can’t use this technique because you can not FTP files to Blogger.What you need to do is create some type of hidden post, or page, that only you can access. This content should have the __utmSetVar(‘exclude-me’) function somewhere in the page. When the page loads, the cookie will be set on your machine. Then you can follow the instructions starting with the filter section.

    Hope that helps…

    Justin

Trackbacks

  1. [...] today i found a web blog with a solution of this problem , thanx to Justin Cutroni for this >> Count Me Out! [...]

  2. [...] I found this online yesterday as a method to avoid skewing Analytics with all your visits to your site. I won’t be able to begin seeing if I don’t show up until tomorrow. (I’ve noticed it doesn’t affect data already in Google Analytics.) http://www.epikone.com/blog/2006/07/11/count-me-out/ That was one thing I had to learn on my own. Also, you’re going to have to do this for each browser. So if you’re testing in both IE & FireFox, then you’ll have to set the cookie on each. [...]

  3. [...] Other great examples of custom filters: Create a filter to learn what words people actually type in to Google before they click on your AdWord, instead of just learning which AdWord gets credit. (I use this one all the time. The only hack I like better is this one.) Force all your reports to give you pages by title instead of URL. [...]

  4. [...] Other great examples of custom filters: Create a filter to learn what words people actually type in to Google before they click on your AdWord, instead of just learning which AdWord gets credit. (I use this one all the time. The only hack I like better is this one.) Force all your reports to give you pages by title instead of URL. [...]

  5. [...] So on the off chance that I haven’t already given enough publicity to this workaround: my favorite answer for a small company is to use this workaround, called “Count me Out!. [...]

  6. [...] Another good way to exclude internal traffic, especially if you don’t have a static IP address, is to use a little hack called Count Me Out. This hack uses the GA custom segment cookie to identify users. [...]

  7. [...] Φαντάζομαι ότι πολλοί από εμάς χρησιμοποιούμε το φοβερό Google Analytics (GA) για να κρατάμε στατιστικά επισκεψιμότητας και κυκλοφορίας της σελίδας μας. Θέλουμε, όμως, να αποκλείουμε από τις μετρήσεις τις επισκέψεις που κάνουμε από τους δικούς μας υπολογιστές. Επειδή οι περισσότεροι διαθέτουμε δυναμικές IP διευθύνσεις από τους ISP δεν είναι δυνατό να ορίσουμε στα φίλτρα του GA ένα εύρος διευθύνσεων που θα θέλαμε να αποκλείσει. Μια πολύ καλή και λειτουργική λύση βρήκα εδώ. Είναι πολύ εύκολη στην υλοποίηση, απλά ακολουθούμε τις οδηγίες και “τρέχουμε” το sciptάκι από όποιον υπολογιστή δεν επιθυμούμε να καταγράφονται οι επισκέψεις. Το δοκίμασα και δουλεύει… Tags: browser, google, stats, διαδίκτυο [...]

  8. [...] Analytics Talk » Blog Archive » Count Me Out! how to exclude your own visit from google analytics stats, a practical howto. interesting technique involving the use of a cookie, which is signaling who you are to the tracking system. (tags: analytics filter google howto electronic_presence) [...]

  9. [...] Google Analytics Hack » Count Me Out! – keep your Google Analytics data pure you should remove all traffic generated by yourself or others that may not be real visitors. For example, if your company has a large call center you should remove the traffic they generate [...]

  10. [...] It’s quiet annoying that every time you visit your own website, google analytics is picking you up as a visitor. After some googling. I found a solution, the trick is to set a cookie on your own computer and setup a filter in analytics ignoring everybody who has this cookie. [...]

  11. [...] I would like to thank, Justin Cutroni, as his blog was the first clear explanation I encountered. [...]

  12. [...] I would like to thank, Justin Cutroni , as his blog was the first clear explanation I encountered. [...]

  13. [...] I think I found a way to exclude myself from the numbers by using a cookie and filter. I’ll have to give the numbers a look over in a few days to see if this works. [...]

  14. [...] IP addresses or addresses – Google Analytics explains how. And (of course) Justin Cutroni also has some great tips for how you can exclude a single computer – especially handy if you have a dynamic IP [...]

  15. [...] #3: Thanks to Phil LeClair for point me to this article, “Count Me Out!” on Analytics Talk, we now have an answer to our question about excluding dynamic IP [...]

  16. [...] Google Analytics Hack » Count Me Out! – keep your Google Analytics data pure you should remove all traffic generated by yourself or others that may not be real visitors. For example, if your company has a large call center you should remove the traffic they generate [...]

  17. [...] Analytics Talk » Blog Archive » Count Me Out! – To keep your Google Analytics data pure you should remove all traffic generated by yourself or others that may not be real visitors. For example, if your company has a large call center you should remove the traffic they generate because it will skew your analytics data.To remove this data we usually use an exclude filter based on IP address, host name or geographic location. While this is effective the results can be a bit ‘broad’. What I mean is you may not want to remove ALL of the traffic from an IP address, host name or geographic location. [...]

  18. [...] There are a variety of ways to filter yourself out of your Google Analytics reporting. We prefer the IP based filter but you can also try the cookie method. [...]

  19. [...] If you’re using Google Analytics, you can simply add a filter to exclude your IP address, but there’s a better way described in the article Count Me Out! [...]

Speak Your Mind

*