Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created December 3, 2009 04:18
Show Gist options
  • Save lsmith/247884 to your computer and use it in GitHub Desktop.
Save lsmith/247884 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),
*/
var _gaq = [['_setAccount', 'UA-XXXXXX-X'],['_trackPageview']];
(function(d) {
var script = d.createElement('script'),
ref = d.getElementsByTagName('script')[0];
script.async = true;
script.src = 'http://www.google-analytics.com/ga.js';
ref.parentNode.insertBefore(script, ref);
})(document);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment