Asynchronous Tracking
11 Feb
The Snippet
The Analytics snippet is a small piece of JavaScript code that you paste into your pages. It activates Google Analytics tracking by inserting ga.js into the page, which in turn provides an API for customizing how your page is tracked. The following snippet represents the minimum configuration needed to track a page asynchronously. It specifies the page’s web property ID and then calls _trackPageview to send the tracking data back to the Google Analytics servers.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement(’script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
(document.getElementsByTagName(‘head’)[0] || document.getElementsByTagName(‘body’)[0]).appendChild(ga);
})();
</script>
To use this on your pages, copy the code snippet above, replacing UA-XXXXX-X with your web property ID. If you need to do more than basic page tracking, see the tracking reference for a list of methods available in the API and see the usage guide for details on using the asynchronous syntax.
Important: If you want to use the asynchronous snippet, you should remove the existing tracking snippet first. We do not recommend using both snippets together on the same page.

Comentarios Recientes