Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Google Analytics Asynchronous Rate Topic   - - - - -

  • Goodies
  • Member
  • Members
  • Join Date: 28-Jul 14
  • 41 posts

Posted 24 August 2014 - 02:16 PM #1


I understand a way to speed up page loading or rendition is by requesting asynchronously loading so those resources that load later are not blocked. No sure where or how to make changes in the code to make this happen.

I made a search and the following changes recommended at least for Google Search Engine

<script type='text/javascript'>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
var ga = document.createElement('script');
ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
<script type="text/javascript">
try {
var pageTracker = _modpagespeed_getRewriteTracker("UA-XXXXX-X");
} catch(err) {}

  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11392 posts

Posted 24 August 2014 - 08:27 PM #2

I don't think you can defer this script since the 'defer' and 'async' attributes only apply to external scripts (I.e. scripts with a 'src' attribute). You can place it in the footer so it's executed last by using a footer.post hook.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.