How to filter myself out of Google Analytics with a dynamic IP address?

£可爱£侵袭症+ 提交于 2019-12-03 10:26:55

Google currently has a browser add-on that will block any visits of yours from showing up in any Analytics. http://tools.google.com/dlpage/gaoptout

Pluses and minuses of this opt-out versus filters are discussed in this blog post.

There are a couple ways of doing this. If you know the range of IP addresses you're accessing your site from (and don't mind filtering them all out) you can set up an "Exclude" filter for that range of IP addresses. If that's too restrictive, you can set a cookie using the Google Analytics code and filter on that. Both techniques are documented at Google's help system.

Alternatively, if you're dynamically producing the pages on the server, you could simply not write the Google Analytics code into the pages in the first place, based on the currently logged in user. On my site, I'm choosing to write the code or not based on a few things, such as whether the website is running in debug mode or if an administrator is logged on.

You can do this by creating a special page on your site that sets a Google Analytics segmentation cookie, using code something like:

<body onLoad="javascript:__utmSetVar('exclude_from_report')">

Then create a custom filter in Analytics to exclude visitors that match the 'exclude_from_report' segment pattern.

Consider using the NoScript plugin for Firefox. Just mark google-analytics.com as an untrusted site and you should be all set. A nice side-benefit: better security in your browser.

Just block the domain where google analytics lives via your system's hosts file:

127.0.0.1 www.google-analytics.com

This is less disruptive than the NoScript plugin mentioned by jdigital, but still makes you effectively invisible to google analytics.

Andy Webber

Setting a cookie to prevent the analytics code from being sent to the browser is by far the best option.

If you're a developer and concerned that you're going to get a bazillion hits while you're developing the site you can add the following line in your analytics tracking code :

 pageTracker._setDomainName(".yourwebsitename.com"); 

Assuming you're hitting a url not ending in .yourwebsitename.com during testing then the tracking code will see your URL is 'localhost' and not 'yourwebsitename.com' and not send any tracking.

You can always setup a proxy to tunnel all of your traffic through. Then simply exclude the proxy's IP from the results.

can't find a way to reply to answers, I second to the hosts file trick: 127.0.0.1 www.google-analytics.com

as it works in all browsers at the same time, as designers often try site in all browsers.

I recommend to use a 127.0.0.1 (localhost) redirect in the HOST file to block all/any type of abusive sites or domain/trackers/analytic and such. For a large list take a look at the WinHelp website. I have and still use it for all my PC's. You also need to look over the list which domains you do want and remark the lines with a # tag in the list.

All instructions are on the site for different operating systems.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!