Created
November 24, 2010 15:09
-
-
Save getify/713779 to your computer and use it in GitHub Desktop.
loading google analytics using LABjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
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
@jimmykhlam I believe it's up to you. Is site functionality less important to you than the analytics? Then put ga first. Otherwise put it last.