Which Google analytics code?


#1

Dear @GulshanKumar
Please tell me is this Analytics code is good for pagespeed ?
or Which format is best for page speed ?
(source : https://developers.google.com/analytics/devguides/collection/analyticsjs/)

<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga(‘create’, ‘UA-XXXXX-Y’, ‘auto’);
ga(‘send’, ‘pageview’);
</script>
<script async src=‘https://www.google-analytics.com/analytics.js’></script>
<!-- End Google Analytics -->


#6

Sorry, initially I didn’t get question. Mistakenly typed some incorrect response. :frowning:


#7

I checked it again!

According to Google, below version may be faster due to asynchronous execution.

<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->

BTW, this plugin may be helpful if your host is faster.