Posted By

paul66 on 01/27/11


Tagged

google Analytics Asynchronous optimised


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

matylla
lawrencetaur


Optimised Google Analytics


 / Published in: JavaScript
 

URL: http://mathiasbynens.be/notes/async-analytics-snippet

Google Analytics is a very popular tool for tracking your website’s user behaviour, and visits. This is simply an optimised version of Google’s asynchronous tracking snippet. To learn what has been optimised, and why it is faster than Google’s own version, follow link.

  1. <!-- asynchronous google analytics change the UA-XXXXX-X to be your site's ID -->
  2. <script>
  3. var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_trackPageview']];
  4. (function(d, t) {
  5. var g = d.createElement(t),
  6. s = d.getElementsByTagName(t)[0];
  7. g.async = true;
  8. g.src = '//www.google-analytics.com/ga.js';
  9. s.parentNode.insertBefore(g, s);
  10. })(document, 'script');
  11. </script>

Report this snippet  

You need to login to post a comment.