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

Nahuel picture Nahuel · Mar 8, 2012 · Viewed 76.6k times · Source

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?

Answer

Nahuel picture Nahuel · Mar 16, 2012

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>