labjs load google analytics

304 Views Asked by At

Has anyone used LABjs for loading google analytics?

Where do you include it in the chain?

I found this script but wasn't sure whether to include my other scripts before or after

$LAB
.script("js/myscripts.js") //here?
.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("js/myscripts.js") //or here?
});

Also, has anyone used LABjs with getclicky? Did you do something similar to the above load chain for google-analytics?

1

There are 1 best solutions below

0
Cogslave On BEST ANSWER

The suggested option is to make another loading chain for google analytics.
Load google analytics script in one chain and your code in the other.

Quote from a gist showing how to load GA with LabJs by Kyle.

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.

I have not used getclicky but I would assume the above answer covers that as well.