Skip to content

Instantly share code, notes, and snippets.

@pherrymason
Created December 10, 2013 09:54
Show Gist options
  • Save pherrymason/7888249 to your computer and use it in GitHub Desktop.
Save pherrymason/7888249 to your computer and use it in GitHub Desktop.
Analytics Tracking
function trackEvent( zone ){
// If ga is available & loaded.
if( typeof(ga)!=='undefined' ){
// https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
// Use universal analytics @todo
}
else
{
var _gaq = window._gaq || []; // For tracking analytics
_gaq.push(['_trackEvent', category, action, value]);
}
}
function trackPageView( url ){
if (typeof(ga)!=='undefined'){
ga('send','pageview',{
'page':url
});
}
else {
var _gaq = _gaq || []; // For tracking analytics
_gaq.push(['_trackPageView', url] );
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment