Google Analytics - Failed to load resource: http://www.google-analytics.com/ga.js

Google AnalyticsHttp Status-Code-404

Google Analytics Problem Overview


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?

Google Analytics Solutions


Solution 1 - Google Analytics

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>

Solution 2 - Google Analytics

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]

Solution 3 - Google Analytics

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

See https://stackoverflow.com/questions/14410974/html5-appcache-causing-problems-with-google-analytics

Solution 4 - Google Analytics

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>

Solution 5 - Google Analytics

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

Solution 6 - Google Analytics

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

Solution 7 - Google Analytics

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.

Solution 8 - Google Analytics

Ensure Fiddler (or similar proxy) is not active.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNahuelView Question on Stackoverflow
Solution 1 - Google AnalyticsNahuelView Answer on Stackoverflow
Solution 2 - Google AnalyticsSKWebDevView Answer on Stackoverflow
Solution 3 - Google Analyticsmatt burnsView Answer on Stackoverflow
Solution 4 - Google AnalyticsMichael YagudaevView Answer on Stackoverflow
Solution 5 - Google AnalyticseQ19View Answer on Stackoverflow
Solution 6 - Google AnalyticsPirateAppView Answer on Stackoverflow
Solution 7 - Google AnalyticsaherokView Answer on Stackoverflow
Solution 8 - Google AnalyticstchelidzeView Answer on Stackoverflow