Optimised Google Analytics

/ Published in: JavaScript
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  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>

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

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.