To improve the script's performance, Google decided to load it asynchronously. "Unlike a traditional installation, asynchronous tracking optimizes how browsers load ga.js so its impact on user experience is minimized. It also allows you to put your Analytics snippet higher in the page without delaying subsequent content from rendering."
Here's the new code for basic tracking, which uses some ideas from Steve Souders:
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; ga.setAttribute('async', 'true'); document.documentElement.firstChild.appendChild(ga); })(); </script>Google Analytics Blog says that the new snippet is a beta feature and changing the code is optional.
The new tracking snippet offers the following benefits:
* Faster tracking code load times for your web pages due to improved browser execution
* Enhanced data collection and accuracy
* Elimination of tracking errors from dependencies when the JavaScript hasn't fully loaded
[quote]Unfortunately, you can't place the script at the bottom of the page if you some advanced features[quote]
ReplyDeleteToo late to try 'I accidentally'
:)
Thanx a lot for providing me great knowledge about the new features of google like-tracking events and more.I also want to share some information to you related to coupons and discounts-I have visited a site that is proving great discounts on network devices and electronic items by On Sale promo code.You can also visit that site for more knowledge.
ReplyDelete"...if you some advanced features like tracking events.", "...visitors would have until the script is executed...", ...
ReplyDeleteeven if I'm german I notice how great the english in this article is...
I tested that "beta" javascript snippet on Currate.com blog site - it does not work as it seems to lock up. I changed it back to original Google Analytics snippet.
ReplyDeleteMeanwhile, keep up with your excellent articles. :)
Robert
Currate.com Developer/Publisher