6th January 2006
Blocking your own views with Google Analytics
This tip applies to anybody running Google Analytics on their own web site.
If you're like me, you've never got the filters to work in Google Analytics. I'm a seasoned programmer; I know all about regular expressions, and yet getting the system to exclude page views from my IP address just doesn't work. I either fail to block anything, or I block everything!
If your web pages use PHP and you have a static IP address, there's an alternative. Simply wrap the Google Analytics code up in the following:
<!-- IP: <?php echo $_SERVER["REMOTE_ADDR"]; ?> -->
<?php if ($_SERVER["REMOTE_ADDR"] != "IP_ADDR") { ?>
<– Google Analytics code –>
<?php } ?>
Replace IP_ADDR with your IP address as reported by the script. For example, mine is 86.7.14.186, so that's exactly what I insert between the quotation marks.
If you have dynamic IP, this technique may still work, but you'll have to keep an eye out for when your IP address changes. You may find that only the last number of your IP address change, in which case you can filter on the remaining three only with a small change to the code.
To find out your IP address, go to www.whatismyip.com. It will show you your IP address and that of your proxy. Note that you may have to use the address of your proxy. The definitive way to find out which IP address to use is to view source on one of your web pages after you have modified it, and look for the IP address, which will be detailed in a comment starting with <!-- IP: in the header.
Note that you may also block traffic from some other people if you have to block based on a proxy IP address. Personally, I'd rather do that, and not have to worry about my own page views appearing in Google Analytics.
David Thomas, The Affiliate Marketer
Comments
20th April 2006
Marketing With Miles said (trackback):
Google Analytics - Blocking Your Ip Address
"I thought that perhaps there must be a reason why I couldnt block my own IP address from showing up in the Google Analytics statistics so I researched it online. I quickly found out I wasnt the only one that was experiencing this problem. David T…
9th June 2006
Rudolf said:
Actually, Google Analytics lets you to exclude traffic in more then one way by using filters.
You can exlude traffic from a domain or IP address, or based on a custom filter. Which gives all the freedom one could desire.
But I just signed up, so maybe it wasn't there at the time of writing. Now it is.
Rudolf
31st October 2006
John said:
I found this very helpful in excluding myself from all sorts of trackers, not just google. Thanks.
21st December 2006
Robert said:
Create a custom filter following the instructions on this page:
Will work for all your dynamic and static IPs. Sets a cookie on your comouter that creates a "no_report" setting environment.
http://www.akamarketing.com/blog/40-google-analytics-excluding-your-visits-despite-having-a-dynamic-ip.html