Tired of waiting for www.google-analytics.com -- can a browser setting "opt me out"?

The 'old school' method, which works with any browser, is to add the following entry to your local hosts file,

127.0.0.1 www.google-analytics.com
127.0.0.1 google-analytics.com
127.0.0.1 ssl.google-analytics.com

This works for all browsers, regardless of whether they support plugins. As long as you don't run a web server on your local machine, these connections are instantly rejected and so don't take very long to fail.

You could also try 0.0.0.0 (never personally tested by me though).

0.0.0.0 www.google-analytics.com
0.0.0.0 google-analytics.com
0.0.0.0 ssl.google-analytics.com

There are many solutions that take the approach of blocking requests before they are even initiated:

  • AdBlock / AdBlock Plus – It's dedicated for blocking ads, but you can configure it to block almost anything.
  • Ghostery – Its main point is taking care of your privacy, it will block GA for you (along with many other tracking scripts). RequestPolicy is its open-source alternative for Firefox.
  • NoScript / ScriptSafe / other script blockers – Blocking JavaScript entirely should solve the problem too.

Downloads for Firefox:

  • AdBlock Plus
  • Ghostery
  • NoScript
  • RequestPolicy

Downloads for Chrome:

  • AdBlock
  • AdBlock Plus
  • Ghostery
  • ScriptSafe

Downloads for Opera:

  • AdBlock
  • AdBlock Plus
  • Ghostery

Ghostery is also available for other browsers.


Adblock Plus or equivalent can do this for you; block anything from hostnames ending in google-analytics.com, and your browser won't even try to communicate with the service. In Adblock Plus, you'd want to add a custom filter with text ||google-analytics.com to produce this result.


For the sake of completeness, although not as easy to set up as the other solutions, you could consider running an ad blocking proxy such as Privoxy. The squid proxy can be configured to block ads as well.

Another option is to run your own DNS server and filter out the badness there, which has the same effect as blocking servers in your hosts file.