Ensure GA is recorded for each page change

This commit is contained in:
Andrew Miner
2015-01-15 11:14:04 -08:00
parent d2b9720e72
commit f0c6c055ff
3 changed files with 20 additions and 4 deletions
+9
View File
@@ -19,6 +19,8 @@ module.exports = class CraftingGuideRouter extends Backbone.Router
@_pageControllers = {}
super options
@on Event.route, => @_recordPageView()
# Backbone.Router Overrides ####################################################################
routes:
@@ -38,6 +40,13 @@ module.exports = class CraftingGuideRouter extends Backbone.Router
# Private Methods ##############################################################################
_recordPageView: ->
if global.env is 'production'
logger.info "Recording GA page view: #{window.location.href}"
ga('send', 'pageview')
else
logger.info "Suppressing GA page view: #{window.location.href}"
_setPage: (controllerName)->
controller = @_pageControllers[controllerName]
if not controller? then throw new Error "cannot find controller named: #{controllerName}"