Skip to content

Instantly share code, notes, and snippets.

@eduardocereto
Created October 2, 2012 18:35
Show Gist options
  • Save eduardocereto/3822158 to your computer and use it in GitHub Desktop.
Save eduardocereto/3822158 to your computer and use it in GitHub Desktop.
GAS firing MaxScroll with sampling
var _gas = _gas || [];
_gas.push(['_setAccount', 'UA-YYYYYY-Y']); // REPLACE WITH YOUR GA NUMBER
_gas.push(['_setDomainName', '.mydomain.com']); // REPLACE WITH YOUR DOMAIN
_gas.push(['_trackPageview']);
_gas.push(['_gasTrackForms']);
_gas.push(['_gasTrackOutboundLinks']);
// Max Scroll on 20% of the pages
if(Math.random() * 100 < 20) {
_gas.push(['_gasTrackMaxScroll']);
}
_gas.push(['_gasTrackDownloads']);
_gas.push(['_gasTrackYoutube', {force: true}]);
_gas.push(['_gasTrackVimeo', {force: true}]);
_gas.push(['_gasTrackMailto']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = '/gas.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment