Fixed Google Analytics Template.

Toxic

Member
I was having issues with Google analytics with one of my websites. when I looked at the source it showed the following:

Code:
    (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','//www.google-analytics.com/analytics.js','ga');
    

    ga('create', 'UA-xxxxxxxx-x', 'auto');
    ga('send', 'pageview');

Surely the URL should be https://www.google-analytics.com/analytics.js and not //www.google-analytics.com/analytics.js ?
 
Hi @Toxic, my understanding is // makes the URL protocol-relative. I checked the newest Analytics snippet code and indeed you're correct that it is now https://

Having said that // is still working fine for me, and also the same is being used here at XF?
 
Last edited:
Indeed "//" is fine as it's protocol relative. I'll leave this here though as making it just pure https is probably preferable these days.
 
Back
Top Bottom