Powered By

Powered by Blogger

Rabu, 02 Desember 2009

New Google Analytics Beta Tracking Code

If you use Google Analytics, you probably know that Google suggests (and it's best like that) to place the code just before the </body> tag so that the code is executed as the last element of the DOM. But unfortunately, you can't always do that, because if you want to track the clicks, you have to insert the Google Analytics code before the first link you want to track.

To improve the script's performance, Google decided to load it asynchronously:

Think of the asynchronous tracking code snippet as a script that uses a "separate lane" to handle part of the processing of your webpage. As the number of cars (or in this case, scripts on your webpage) increases, the asynchronous tracker uses this lane to reduce webpage load time. Websites that use many scripts or rely on rich media content will especially benefit from this new method, but even lightweight sites will see improvements.

And released a new, beta tracking code (optional):
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);

(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');


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

Tidak ada komentar:

Posting Komentar