From 4cef967618e6331e9513a0f64215789eb19c323e Mon Sep 17 00:00:00 2001 From: Andrew Cobby Date: Wed, 10 Oct 2012 14:08:14 +1100 Subject: [PATCH] Trialling custom pageview tracking through Google Analytics --- templates/index.twig | 1 - web/js/routers/AppRouter.js | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/index.twig b/templates/index.twig index f458c5a..d9cc7f5 100644 --- a/templates/index.twig +++ b/templates/index.twig @@ -16,7 +16,6 @@ var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-27879276-5']); - _gaq.push(['_trackPageview']); {% if not app.debug %} (function() { diff --git a/web/js/routers/AppRouter.js b/web/js/routers/AppRouter.js index 6a29885..4aca1ff 100644 --- a/web/js/routers/AppRouter.js +++ b/web/js/routers/AppRouter.js @@ -28,6 +28,7 @@ TGM.Routers.AppRouter = Backbone.Router.extend({ this.models.activeBudget = this.models.userBudget; TGM.vent.trigger('activeBudget', this.models.userBudget); TGM.vent.trigger('showSidePane', 'budget-allocator'); + _gaq.push(['_trackPageview']); } }, @@ -43,6 +44,7 @@ TGM.Routers.AppRouter = Backbone.Router.extend({ var fetchSuccess = _.bind(function() { TGM.vent.trigger('activeBudget', this.models.activeBudget); if (this.models.activeBudget != this.models.userBudget) { + _gaq.push(['_trackPageview']); _gaq.push(['_trackEvent', 'Budget', 'View', this.models.activeBudget.id]) } }, this); @@ -78,16 +80,18 @@ TGM.Routers.AppRouter = Backbone.Router.extend({ this.models.activeBudget = this.models.userBudget; TGM.vent.trigger('activeBudget', this.models.activeBudget); TGM.vent.trigger('showSidePane', 'budget-allocator'); + _gaq.push(['_trackPageview']); } }, saveBudget: function(id) { if (id && (this.models.userBudget.id != id || !$.jStorage.get('clientId'))) { - this.goto("budget", id); + return this.goto("budget", id); } TGM.vent.trigger('showSidePane', 'save-budget'); + _gaq.push(['_trackPageview']); }, viewBudgets: function() @@ -112,6 +116,7 @@ TGM.Routers.AppRouter = Backbone.Router.extend({ } TGM.vent.trigger('showSidePane', 'other-budgets'); + _gaq.push(['_trackPageview']); }, goto: function()