Skip to content

Instantly share code, notes, and snippets.

@jessefreeman
Created November 18, 2013 16:43
Show Gist options
  • Select an option

  • Save jessefreeman/7531064 to your computer and use it in GitHub Desktop.

Select an option

Save jessefreeman/7531064 to your computer and use it in GitHub Desktop.
A simple Google Analytics tracking plugin for your Impact games.
ig.module(
'bootstrap.plugins.tracking'
)
.requires(
)
.defines(function () {
Tracking = ig.Class.extend({
debug: true,
init: function (account) {
if (typeof _gaq != 'undefined') {
_gaq.push(['_trackPageview']);
if (account)
this.setAccount(account);
}
else {
this.analyticsNotFound();
}
},
setAccount: function (account) {
if (typeof _gaq != 'undefined')
_gaq.push(['_setAccount', account]);
else
this.analyticsNotFound();
},
trackPage: function (url) {
if (typeof _gaq != 'undefined')
_gaq.push(['_trackPageview', url]);
else
this.analyticsNotFound();
},
trackEvent: function (category, action, label, value) {
if (typeof _gaq != 'undefined')
_gaq.push(['_trackEvent', category, action, label, value]);
else
this.analyticsNotFound();
},
analyticsNotFound: function () {
if (this.debug) console.log("Tracking object not found.");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment