keesspoelstra opened a new issue #1871: Proposal: use GA script for modern 
browsers (where applicable?)
URL: https://github.com/apache/incubator-pagespeed-mod/issues/1871
 
 
   Looking at:
   
https://developers.google.com/analytics/devguides/collection/analyticsjs/#alternative_async_tracking_snippet
   
   It seems that for the larger part we can detect modern browsers by useragent?
   Rewriting an existing google tag implementation could be done by replacing 
the 
   
   `(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');`
 
   
   Pattern by
   
   `window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new 
Date;`
   
   Plus:
   `<script async src='https://www.google-analytics.com/analytics.js'></script>`
   
   Looking at the code, we don't have to replace, because the loader code 
already checks if window.ga is present, which we can make sure of, we only have 
to insert the window.ga script + async script src as early as possible.
   
   I imagine a lot of groundwork is already in the make_google_analytics_async 
filter: https://www.modpagespeed.com/doc/filter-make-google-analytics-async
   
   Thoughts on configuration and implementation? 
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to