109

I've been noticing this error on Chrome's console for a while now:

enter image description here

I modified Google's script so that it logs the error, because it uses try{} catch{}, and this is what I got:

enter image description here

I haven't noticed considerable changes in the stats, it's always in ups and downs.

Also, this isn't only on my sites, but fricking everywhere. I haven't found bug reports or anything like that.

If I go to http://www.google-analytics.com/ga.js on the browser, it loads normally.

Does anyone have a clue of what causes this?

ronalchn
  • 12,225
  • 10
  • 51
  • 61
Nahuel
  • 3,555
  • 4
  • 21
  • 28
  • 2
    Are you behind a proxy or firewall? – shanabus Mar 08 '12 at 14:09
  • 4
    What happens if you try to directly open [http://www.google-analytics.com/ga.js](http://www.google-analytics.com/ga.js) in a browser? It sounds like you might be blocking or redirecting google-analytics.com in a local HOSTS file. – mike Mar 08 '12 at 16:26
  • 32
    Check that you're not using AdBlock or something that may be blocking loading Google Analytics. – travis-146 Mar 14 '12 at 21:20
  • Yes. I disabled AdBlock and now it loads it fine. Didn't think of that, thank you :) – Nahuel Mar 15 '12 at 23:20
  • 3
    I had this problem using an VPN, turning it off removed the issue. – nilsi Feb 16 '16 at 15:47
  • Other users using ABP will still block your data from being sent. I have mocked up a workaround here: http://kennystechtalk.blogspot.com/2016/03/adblockanalytics.html – Ken Sharp Mar 02 '16 at 20:59

8 Answers8

197

It was a problem with AdBlock. I disabled it and now it loads it normally.

yagudaev suggests (read answers below) that in order to keep AdBlock from blocking Google Analytics, you need to edit the snippet provided and explicitly use https:// instead of the protocol-relative URL by default. This means changing

'//www.google-analytics.com/analytics.js'

into

'https://www.google-analytics.com/analytics.js'

Example:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-XX', 'auto');
  ga('send', 'pageview');
</script>
Nahuel
  • 3,555
  • 4
  • 21
  • 28
  • 1
    Same here. It makes you feel so silly when something like this happens. I remember spending half a day fixing some image not downloading from the server, only to realise that having named it 'banner.jpg' made AdBlock block it as well. Thanks for the tip. – Mosselman Mar 15 '13 at 12:25
  • 3
    Yet they allow ads in Gmail, WTF AdBlock, WTF – Nick Shvelidze Jul 21 '13 at 17:36
  • I used http://winhelp2002.mvps.org/hosts.htm file to do my adblocking and thought GA changed their setup because I couldn't access anything from the domain. whooops. – andrewleung Nov 22 '13 at 18:11
  • 6
    Does it mean that GA dont count people with Addblock? – Adam Pietrasiak Jan 05 '14 at 18:27
  • 1
    @AdamPietrasiak Yes, it does mean unfortunately. :( Some regional filer list contains rules which are completely blocking the GA, GTM and all awesome Google stuff... even the MVT test (A/B tests) won't work if you use experiment in GA. I cannot understand why is good for the people (eventually the filer list maintainers)... A common user won't configure the white list and any other settings... they will just install the plugin and that's it... and we are just loosing the data in stats. – Sas Sam Sep 05 '14 at 09:08
  • It was the [ghostery extension](https://chrome.google.com/webstore/detail/ghostery/mlomiejdfkolichcflejclcbmpeaniij) for me... whitelisting works – tutuDajuju Nov 13 '14 at 15:17
  • 1
    This will have no effect whatsoever. The domain is blocked so changing the protocol is aimless. – Ken Sharp Mar 02 '16 at 21:00
  • 3
    indeed Ken, unfortunately for me even though I changed the http to https I can still see this in debug console of the browser (chrome + adBlock plus): GET https://www.google-analytics.com/analytics.js net::ERR_BLOCKED_BY_CLIENT – ovi Mar 10 '16 at 20:57
  • @Ovi-WanKenobi did you try the the white filter suggestion? `@@|http://www.google-analytics.com` – user3494047 May 05 '17 at 19:22
  • For any others - I was seeing a similar issue, but it wasn't because of Adblock, it was my Avast security extension. I viewed my site with another browser (or view in Incognito) which didn't have any plugins and no errors! – Lushawn Oct 12 '22 at 13:33
8

It could also be your hosts file, here's mine:

$ grep -ni "google-analytics.com" /etc/hosts
6203:# 127.0.0.1  ssl.google-analytics.com #[disabled = Firefox issues]
6204:127.0.0.1  www.google-analytics.com #[Google Analytics]
SKWebDev
  • 161
  • 1
  • 5
4

If it's an offline app (ie, you've defined a cache manifest) be sure to allow the network request.

See HTML5 Appcache causing problems with Google Analytics

Community
  • 1
  • 1
matt burns
  • 24,742
  • 13
  • 105
  • 107
3

The reason you are running into problems is because AdBlock will block this script if and only if it does not go through https. Notice the error you get it contains an http: protocol reference.

All you need to do is change the snippet to force it to go through an ssl connection by adding an explicit protocol instead of the protocol relative url that is the default.

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-XX', 'auto');
  ga('send', 'pageview');
</script>
Michael Yagudaev
  • 6,049
  • 3
  • 48
  • 53
  • That's actually a good tip to avoid losing stats on users who use AdBlock. Since there already is an accepted answer, I'll add your tip to it. Thanks! – Nahuel Jan 15 '16 at 00:24
  • 4
    https makes no difference at all. The host is blocked, not the URL. – Ken Sharp Feb 14 '16 at 00:34
  • 1
    indeed Ken, unfortunately for me even though I changed the http to https I can still see this in debug console of the browser: GET https://www.google-analytics.com/analytics.js net::ERR_BLOCKED_BY_CLIENT – ovi Mar 10 '16 at 20:56
2

This error is commonly caused due to one of the extensions installed within Chrome.
There are a few ways to debug and solve an ERR_BLOCKED_BY_CLIENT message.

  • Disable the extension.
  • Whitelist the domain.
  • Debug the issue.

I would recommend to find more detail at How to Solve ERR_BLOCKED_BY_CLIENT

eQ19
  • 9,880
  • 3
  • 65
  • 77
2

2019 update

This has become very widespread now.

Solutions

  1. Ask people to unblock your website, (bad idea from personal experience)
  2. Host google analytics script locally (bad idea) because google says so HERE

Referencing the JavaScript file from Google's servers (i.e., https://www.googletagmanager.com/gtag/js) ensures that you get access to new features and product updates as they become available, giving you the most accurate data in your reports.

  1. Use Server side analytics. This is what people are doing nowadays. If you are on node.js, use a library such as analytics or universal-analytics
PirateApp
  • 5,433
  • 4
  • 57
  • 90
1

I've noticed same thing on my browser some time ago. Did you sing in to chrome using your Google account maybe? Or did you choose in any way to opt-out from collecting data on Google Analytics ?

Maybe Google remembers that option and uses it on Chrome when you are singed in..

BTW. I can normally open http://www.google-analytics.com/ga.js in browser, it just doesn't work when automatically loaded.

aherok
  • 622
  • 7
  • 17
0

Ensure Fiddler (or similar proxy) is not active.

tchelidze
  • 8,050
  • 1
  • 29
  • 49