100

Recently (past few weeks) my web browsing is often very slow, and it is often the case at these times that the status bar reads "waiting for www.google-analytics.com".

Is there any browser setting that will tell Google that I do not wish to be a participant in their analytics program, so the page won't even attempt to contact Google? Can individuals "opt out" of this in some way?

6
  • 19
    What about NoScript and similar programs?
    – arne
    Jun 24, 2013 at 13:34
  • 3
  • +1 to arne's comment. I block google analytics, as well as numerous other scripts, with NoScript. This is a FireFox-specific extension.
    – Kaz
    Jun 24, 2013 at 19:19
  • The design of the webpage is a factor here. If there are a small number of sites that bother you, you could raise it with them. Jun 25, 2013 at 10:58
  • Does Google analytics get used for estimating browser usage share? Does opting out of tracking mean opting out of browser usage share statistics? Jun 25, 2013 at 15:35

8 Answers 8

97

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
12
  • 36
    0.0.0.0, a null route, is better. If you're running your own web server you'll start to get 404s if your route to localhost. Jun 24, 2013 at 15:14
  • 2
    0.0.0.0 is not a "null route". The value has different meanings in different circumstances. In BSD-derived stacks, a 0.0.0.0 entry in the route table does represent the "default route". But the default route is not used for connection attempts to the address 0.0.0.0.
    – Kaz
    Jun 24, 2013 at 19:25
  • 4
    Yes, it is a null route. Jun 24, 2013 at 19:44
  • 4
    @Sam, why would you get in trouble?
    – Adrian
    Jun 25, 2013 at 5:10
  • 2
    These "toward myself" or "toward the end of the Internet" routing technics are slightly too late. It is much faster just to not start the TCP connection toward these spying^Wadvertisement servers. The 3 tools quoted by Gronostaj are striking there (ASAP)!
    – dan
    Jun 25, 2013 at 10:44
35

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:

Downloads for Chrome:

Downloads for Opera:

Ghostery is also available for other browsers.

7
  • 27
    Blocking javascript entirely to prevent Google Analytics is like blowing up a pound because a puppy peed on your rug.
    – Jeff
    Jun 24, 2013 at 21:21
  • 17
    @Jeff: you mean, totally awesome?
    – Dancrumb
    Jun 25, 2013 at 1:00
  • 1
    NoScript can be set to only block a blacklist: one needn't block JavaScript entirely to block scripts from some host.
    – andyg0808
    Jun 25, 2013 at 2:37
  • 1
    @Jeff: Pound? Is that pound-mass, pound-force, GBP, or something else? Jun 25, 2013 at 12:36
  • 5
    @Jeff: No, I wasn't joking; I wasn't familiar with the US usage. But I now get your joke. :-) Jun 25, 2013 at 14:43
29

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.

7

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.

1
  • 3
    +1 for dealing with these things at the proxy level. Even in small businesses, where you'd have to maintain just a handful of Firefox installations, things get easily burdensome. Jun 25, 2013 at 8:56
3

There is a plugin Google Disconnect for Firefox which will block Google on non-Google pages, including analytics. There is a similar plugin for Chrome, Disconnect.

2

I use Request Policy for firefox. It's a bit like ghostery, in that it allows you to whitelist and blacklist cross site requests, but isn't explicitly focused on privacy.

It's pretty configurable, but I set mine the blacklist by default

E.g. to use stack overflow sites:

  • I allow any requests to ajax.googleapis.com globally
  • I allow requests to stackauth.com and stackexchange.com and sstatic.com from the particular site.

Everything gets blocked and doesn't impact pageload time or allow for 3rd party tracking, but the page gets little boxes you can click to load things you didn't cover by default.

0

I did not want to block GoogleAnalticsObject because I have several projects under development, AND I want them to register if I hit the external-hosted site, so messing with the hosts file is not an option. Instead, I used an "asp:Placeholder" tag to wrap the Jscript and set visibility=false when localhost, otherwise =true. Pretty simple and does the job quietly.

2
  • This approach seems inapplicable, since the question appears to be about other websites, where you don't have control over the source. (I agree the question could have been clearer on that)
    – Ben Voigt
    Jun 23, 2016 at 19:02
  • Good point; I read the question as a “Developer” where my app was hung-loading, and not as a user – and in that regard I agree with the hosts-mod solution :o)
    – Alan Hord
    Jun 23, 2016 at 23:51
0

Had this problem, just cleared the DNS cache and everything is back to normal. In Chrome go to chrome://net-internals/#dns and press clear host cache

1
  • Didn't work for me.
    – Jagular
    Jul 12, 2017 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .