Ensure GA is recorded for each page change
This commit is contained in:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user