Issue with google analytics implementation


I’m trying to impletement google analytics on my website :
I did impletement the line like describe in the documentation :
{{ template "_internal/google_analytics.html" . }}

And the analytics snippet is present in the source of the page, but i have no visits in analytics (even myself, and i don’t have any filters).
I installed the google tag assistant on chrome to see if the snippet was correct, and i have this error :

No HTTP response detected
With this description :
Missing HTTP Response denotes that, while the Google Analytics code was detected in the page source, the script itself did not execute. Each time the Google Analytics script executes, we expect an HTTP Response carrying the tracking request to Google’s servers.
This means that the Google Analytics code is not implemented properly on the page and no data will be collected.

I don’t know what to do, anyone has this issue ?


1 Like

Hi Jerome,

So, I’ve taken a look at this and I think I might have found the issue. In your analytics tracking code, the 4th line look like this:

See how // is omitting the HTTP / HTTPS. That means the protocol will be automatically using http if you current browsing session is http and https otherwise. Since your site doesn’t support https, the request will be sent to - which in theory should be redirected to https, but…

I tried setting up my code with http on my website and indeed I got the same error. So, could you please try to add the tracking code manually (you will find it in the admin tab of your analytics console) in your website ( instead of the Hugo template ) and make sure the protocol is “https”. This should fix the issue.

So, I think this is not the issue… I was getting an error on my test because my site is HTTPS Only, which was blocking the google analytics code to be fetched using http (normal). I have tried with relative url and http and it works fine. By the way, are you still experiencing issues? I’ve checked your website using the Google Tag Assistant and it doesn’t show any error.