Skip to content

Instantly share code, notes, and snippets.

@kangax
Forked from lsmith/gist:247884
Created December 3, 2009 04:25
Show Gist options
  • Save kangax/247885 to your computer and use it in GitHub Desktop.
Save kangax/247885 to your computer and use it in GitHub Desktop.
<script>
/* Alternate snippet to asynchronously embed the Google Analytics script.
* This requires the following things of the pages that will contain it:
* 1. the page only include one GA tracker (common case),
* 2. the page is not be behind SSL (http, not https),
* 3. this script block can be in the <head> or <body> elements
*/
var _gaq = [['_setAccount', 'UA-XXXXXX-X'],['_trackPageview']];
(function(d) {
var script = d.createElement('script'),
head = d.getElementsByTagName('head')[0] || d.documentElement;
script.async = true;
script.src = 'http://www.google-analytics.com/ga.js';
head.insertBefore(script, head.firstChild);
})(document);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment