javascript - Google analytics code -
i wondering why google not offer simpler , shorter way of initializing ga.js code this:
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-xxxxx-y']); _gaq.push(['_trackpageview']); </script> <script src="//google-analytics.com/ga.js" async="true" type="text/javascript"></script> original solution create utilize of javascript check protocol, set async flag etc, etc..
are there downsides solution?
client's browser may not back upwards async attribute. google's code dynamically creating script tag load script asynchronously anyway. if code not loaded asynchronously user may have bad experience. imagine in user's country google blocked authorities , user uses browser not supports async. if happens user's page block until http://google-analytics.com/ga.js timeout, may take while...
for farther reading on topic can recommend you:
http://www.phpied.com/non-onload-blocking-async-js/ http://www.amazon.com/gp/product/b008cqa8ba/ javascript google-analytics-api
No comments:
Post a Comment