Skip to content

Instantly share code, notes, and snippets.

@simontabor
Created April 24, 2013 14:22
Show Gist options
  • Save simontabor/5452497 to your computer and use it in GitHub Desktop.
Save simontabor/5452497 to your computer and use it in GitHub Desktop.
GoSquared Tracking for Backbone.js
var MyRouter = Backbone.Router.extend({
routes: {
// your routes
},
initialize: function() {
// we must listen to all router events and track a pageview each time
this.on('all',function() {
// the router has changed!
GoSquared.q = GoSquared.q || [];
GoSquared.q.push(['TrackView']);
});
}
// ........ the rest of your code
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment