Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I block or remove the Google Analytics code so that it does not load when I visit a web page?

share|improve this question

migrated from May 13 '11 at 1:04

This question came from our site for professional and enthusiast programmers.

What browser are you using? – Mateen Ulhaq May 13 '11 at 0:35
@muntoo i am using google chrome – sarsar May 13 '11 at 0:48
Grease Monkey may be worth an Investigation – Dave Jun 7 '15 at 9:16

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:


you will see strings like that:

# localhost name resolution is handled within DNS itself.
#       localhost
#   ::1             localhost

add these strings to the end of file:  localhost  localhost  localhost  localhost  localhost  localhost

that will make all google analytics calls local, i.e. not to actual GA server

share|improve this answer
That’s not right at all; those lines just redirect any local connections to Google’s Analytics servers: the opposite of what was intended. – Synetech May 13 '11 at 18:13
And also this method doesn't work if a new ip is added by google. – Ortomala Lokni Jan 30 '15 at 21:37

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:
  • ScriptSafe Extension. Blocks scripts.

share|improve this answer

You can use a browser plugin. It's not that hard as google's analytics JS is always the same URL.


you could set to 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 to a known server that will serve an empty js file.

Note: I believe the google analytics url is Though I could be wrong.

share|improve this answer

I just noticed that Chrome (at least v.12) does not request but rather knows the direct IP. blocking in hosts file works for Firefox, other browsers, direct wget, but Chrome still opens the 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

share|improve this answer

just put this into AdBlock (for chrome or firefox) and it should work.

share|improve this answer

You must log in to answer this question.