Skip to content

Instantly share code, notes, and snippets.

@getify
Created November 24, 2010 15:09
Show Gist options
  • Save getify/713779 to your computer and use it in GitHub Desktop.
Save getify/713779 to your computer and use it in GitHub Desktop.
loading google analytics using LABjs
<!DOCTYPE html>
<html>
<head>
<title>LABjs Demo</title>
</head>
<body>
<!-- some stuff -->
<script src="/js/LAB.js"></script>
<script>
$LAB
.script(('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js')
.wait(function(){
var pageTracker = _gat._getTracker("UA-XXXXX-X");
pageTracker._trackPageview();
});
</script>
</body>
</html>
@getify
Copy link
Author

getify commented Nov 23, 2011

i recommend loading google analytics with an entirely separate chain. It's neither dependent on, nor a depdency of, any other code in your page. so load the rest of the code in your page in one chain, and use a separate chain for google analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment