How can I block or remove the Google Analytics code so that it does not load when I visit a web page?
5 Answers
If you want to be invisible to google analytics of some site - the best way to do it is to overwrite Google Analytics URL in windows hosts file:
Open this file in notepad:
C:\Windows\System32\drivers\etc\hosts
you will see strings like that:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
add these strings to the end of file:
209.85.225.113 localhost
209.85.225.138 localhost
209.85.225.139 localhost
209.85.225.100 localhost
209.85.225.101 localhost
209.85.225.102 localhost
that will make all google analytics calls local, i.e. not to actual GA server
- 147
You have a few options for extensions you can use. Here they are, in order of most likely to work, and least likely:
- Ghostery Extension. It'll block all well-known web-bugs - that means Analytics.
AdBlock / Adblock Plus / uBlock Extension. Add the following code to your manual filters:
http://www.google-analytics.com/ga.jsScriptSafe Extension. Blocks scripts.
- 31,511
- 3,728
I just noticed that Chrome (at least v.12) does not request http://www.google-analytics.com/ga.js but rather knows the direct IP. blocking www.google-analytics.com in hosts file works for Firefox, other browsers, direct wget, but Chrome still opens the ga.gs file (I cleared it's cache). Probably there are too many advices on the Internet how to use hosts file, so they "hacked" this method of avoiding their grip, at least in their own browser
You can use a browser plugin. It's not that hard as google's analytics JS is always the same URL.
OR
you could set google-analytics.com to 127.0.0.1 in your host file. Effectively blocking all google analytics js. If you prevent it from keep pinging the server and trying to get the document, you could point google-analytics.com to a known server that will serve an empty js file.
Note: I believe the google analytics url is google-analytics.com/ga.js Though I could be wrong.
- 131
just put this http://www.google-analytics.com/ga.js into AdBlock (for chrome or firefox) and it should work.
- 119