Is 'make_google_analytics_async' filter still relevent?

43 views
Skip to first unread message

John

unread,
Jun 21, 2016, 4:54:09 PM6/21/16
to mod-pagespeed-discuss
The mod-pagespeed filter 'make_google_analytics_async' makes Google Analytics Asynchronous.

According to the documentation (https://developers.google.com/speed/pagespeed/module/filter-make-google-analytics-async#configuration) it looks for Google Analytics snippet such as the following:

<script type="text/javascript">
 
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document
.write(unescape("%3Cscript src=" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
 
try {
   
var pageTracker = _gat._getTracker("UA-XXXXX-X");
    pageTracker
._trackPageview();
 
} catch(err) {}
</script>


The above appears to be the legacy gs.js which has been replaced by the universal analytics tracking code that uses analytics.js.  According to https://developers.google.com/analytics/devguides/collection/analyticsjs/ the new universal analytics tracking code snippet is:

<!-- Google Analytics -->
<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-XXXXX-Y', 'auto');
ga
('send', 'pageview');
</script>
<!-- End Google Analytics -->

Since the 'make_google_analytics_async' filter only performs simple string matches to find the legacy Google Analytics snippets, it will not work when using the current universal analytics snippet.  Can someone confirm this?
It's my understanding that the universal analytics snippet is asynchronous already. So this filter has no benefit?  Can someone confirm this also?

If I'm way off then please correct me.  Thanks!



Reply all
Reply to author
Forward
0 new messages