GET https://www.google-analytics.com/analytics.js net::ERR_CONNECTION_REFUSED

11,312

Solution 1

I have just looked at your Source Code and can see that you have not placed your Google Analytics Tracking Code between your <head> and </head> tags. Try placing the code between these tags and see how you get on. Let me know if you are still having a problem!

Solution 2

I got this same error today, and eventually figured out it had to do with my new Eero home wifi network. I turned off "Ad blocking (beta)" in the Eero networking prefs. Upon doing so, the analytics.js loaded just fine.

Some other networking tools may have similar functionality, so check those out if the other solutions don't work.

Solution 3

To anyone that is having this problem, i came across it resently and i found out that it was a problem with my router. I dont really know what it was, but this error only happened on my cellphone and PC when they where connected to it. So reseating the rooter did the trick.

This is probably the answer if the problem only happens in one network. If it happens in another don't even bother.

Share:
11,312
Mitko Gurbanski
Author by

Mitko Gurbanski

Updated on June 05, 2022

Comments

  • Mitko Gurbanski
    Mitko Gurbanski almost 2 years

    I am facing a big issue on my website.

    The problem is, because of some reason my analytics code link refuses to talk with the following link:

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

    and gives me this error in the console:

    GET https://www.google-analytics.com/analytics.js net::ERR_CONNECTION_REFUSED
    

    I have contacted the Google Analytics Support but useless. They told me to copy the analytics code exactly as it's shown.

    <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-xxxxxxx-x', 'auto');
      ga('send', 'pageview');
    
    </script>

    I am using Managed Wordpress Hosting from GoDaddy. Is there anyone who faced this problem?

    Thank you, Mitko

  • Mitko Gurbanski
    Mitko Gurbanski about 7 years
    The code is placed in header tags as recommendation from google. I think there is no possible issues headed by the tags.
  • Craig
    Craig about 7 years
    Are you sure? If you are using Google Chrome, right click on your website and select 'View Source'. You will see that the Google Tracking Code has not been entered. Do you have access to your 'header.php' file?
  • Mitko Gurbanski
    Mitko Gurbanski about 7 years
    I don't know how i missed that. I correct that but still same problem.
  • Craig
    Craig about 7 years
    I have had another look but the code is still not appearing between your 'head' tags. If you have access to your header.php file, you can enter your Google Tracking Code directly between your 'head' tags. Failing that, you could use a Plugin like en-gb.wordpress.org/plugins/wordpress-seo where there is an option to simply enter your Google Analytics Tracking ID.
  • Craig
    Craig about 7 years
    Glad to see my input was of some use. Did you use a Plugin or did you insert your Google Tracking Code directly into your 'header.php' file? If the latter, and you are not the theme developer, make sure to place your header.php file into your child theme. Otherwise, you will need to keep adding your Google Tracking Code to your header.php file, every time you process a Theme Update. Here is a link on how to create a Child Theme: codex.wordpress.org/Child_Themes Good luck with your website!
  • Mitko Gurbanski
    Mitko Gurbanski about 7 years
    Because of some reason i can't connect to analytics.js directory on google's server. That is why it won't work only for me.
  • Craig
    Craig about 7 years
    You are all sorted now though, yeah?
  • Leo
    Leo almost 7 years
    I even get the error for analytics.google.com/analytics/web, using hotel internet, so that may explain it.
  • theblackips
    theblackips about 4 years
    Same for me, I wonder how many Devs working from home this had bitten...
  • fviktor
    fviktor almost 4 years
    In my case Bitdefender's Anti-Tracker feature blocked analytics.js. Turning that feature off helped with the development. However, it makes the effectiveness of analytics based on files from external sources questionable in the future.