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

98

21

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?

mrblint

Posted 2013-06-24T13:28:46.390

Reputation: 813

A more important question would be: can these "side" scripts really block the rest of the webpage download? I'm really curious about this. – André Chalella – 2015-03-13T20:11:22.177

18What about NoScript and similar programs? – arne – 2013-06-24T13:34:57.100

3https://addons.mozilla.org/en-US/firefox/addon/requestpolicy/ – lesmana – 2013-06-24T17:18:48.527

+1 to arne's comment. I block google analytics, as well as numerous other scripts, with NoScript. This is a FireFox-specific extension. – Kaz – 2013-06-24T19:19:41.640

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. – Simon Gibbs – 2013-06-25T10:58:36.233

Does Google analytics get used for estimating browser usage share? Does opting out of tracking mean opting out of browser usage share statistics? – James Haigh – 2013-06-25T15:35:52.810

Answers

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

EightBitTony

Posted 2013-06-24T13:28:46.390

Reputation: 3 741

The big disadvantage of this approach is loading page for about 5 sec until GA request fails – Artur Beljajev – 2017-03-08T22:28:31.670

Not sure what this does but it works – frenchie – 2017-05-21T14:29:07.527

350.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. – Darth Egregious – 2013-06-24T15:14:52.307

20.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 – 2013-06-24T19:25:06.793

4Yes, it is a null route. – Darth Egregious – 2013-06-24T19:44:55.180

There are a number of freebie websites where you can download a hosts file that blocks tracking cookies. I'm sure I will get in trouble if I post a link so just do a search for "Blocking Unwanted Connections with a Hosts File" and you will be rewarded. – Sam – 2013-06-25T01:00:00.850

4@Sam, why would you get in trouble? – Adrian – 2013-06-25T05:10:39.277

2These "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 – 2013-06-25T10:44:48.913

0.0.0.0 is a valid IP address. At least, software had better NOT be special casing it. The default route is 0.0.0.0/0. Very different from 0.0.0.0/32. – Zan Lynx – 2013-06-26T02:00:13.717

This approach has the additional advantage that it works independently of browser settings / browser extensions, so that if you need to use Firefox or IE for some reason, your decision to block Google Analytics will be enforced, too. – jstarek – 2013-06-26T10:22:30.630

0.0.0.0 will take a long time to fail for me, as it waits until TCP times out. 127.0.0.1 fails instantaneously as it is actually always reachable. – ithisa – 2013-06-26T12:44:52.307

On my Debian box, both 0.0.0.0 and 127.0.0.1 connect to the local apache instance from a web browser. So I can't see there being any difference in performance frankly. – EightBitTony – 2013-06-26T13:18:35.203

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.

gronostaj

Posted 2013-06-24T13:28:46.390

Reputation: 33 047

25Blocking javascript entirely to prevent Google Analytics is like blowing up a pound because a puppy peed on your rug. – Jeff – 2013-06-24T21:21:18.520

17@Jeff: you mean, totally awesome? – Dancrumb – 2013-06-25T01:00:21.617

1NoScript can be set to only block a blacklist: one needn't block JavaScript entirely to block scripts from some host. – andyg0808 – 2013-06-25T02:37:43.390

3 great tools providing information (Ghostery) and protection (AdBlock & NoScript). – dan – 2013-06-25T10:37:38.527

@Jeff: Pound? Is that pound-mass, pound-force, GBP, or something else? – James Haigh – 2013-06-25T12:36:41.130

@JamesHaigh: Not sure if you're joking, but the the US 'pound' is a common term for an animal shelter, it typically means one that is run by a government agency which is also responsible for collecting strays. Wiki link

– Jeff – 2013-06-25T13:49:37.327

3@Jeff: No, I wasn't joking; I wasn't familiar with the US usage. But I now get your joke. :-) – James Haigh – 2013-06-25T14:43:54.097

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.

Aaron Miller

Posted 2013-06-24T13:28:46.390

Reputation: 8 849

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.

Darth Egregious

Posted 2013-06-24T13:28:46.390

Reputation: 273

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. – Marcello Romani – 2013-06-25T08:56:44.010

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.

Ruud

Posted 2013-06-24T13:28:46.390

Reputation: 282

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.

LukeN

Posted 2013-06-24T13:28:46.390

Reputation: 121

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.

Alan Hord

Posted 2013-06-24T13:28:46.390

Reputation: 11

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 – 2016-06-23T19:02:38.530

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 – 2016-06-23T23:51:24.277

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

frenchie

Posted 2013-06-24T13:28:46.390

Reputation: 301

Didn't work for me. – Jagular – 2017-07-12T22:32:32.183