track pageloads with google analytics. fixes #1012

This commit is contained in:
Connor Turland 2017-01-26 00:27:26 +00:00
parent db81962c91
commit 18086090f2
2 changed files with 9 additions and 4 deletions

View file

@ -39,7 +39,7 @@ const _Router = Backbone.Router.extend({
var navigate = function() { var navigate = function() {
self.timeoutId = setTimeout(function() { self.timeoutId = setTimeout(function() {
self.navigate('') self.navigateAndTrack('')
}, 300) }, 300)
} }
@ -121,7 +121,7 @@ const _Router = Backbone.Router.extend({
path += '/' + DataModel.Maps.Mapper.mapperId path += '/' + DataModel.Maps.Mapper.mapperId
} }
self.navigate(path) self.navigateAndTrack(path)
} }
var navigateTimeout = function() { var navigateTimeout = function() {
self.timeoutId = setTimeout(navigate, 300) self.timeoutId = setTimeout(navigate, 300)
@ -202,6 +202,11 @@ const _Router = Backbone.Router.extend({
const Router = new _Router() const Router = new _Router()
Router.navigateAndTrack = (fragment, options) => {
Router.navigate(fragment, options)
ga && ga('send', 'pageview')
}
Router.intercept = function(evt) { Router.intercept = function(evt) {
var segments var segments

View file

@ -206,9 +206,9 @@ const Visualize = {
var t = Active.Topic var t = Active.Topic
if (m && window.location.pathname !== '/maps/' + m.id) { if (m && window.location.pathname !== '/maps/' + m.id) {
Router.navigate('/maps/' + m.id) Router.navigateAndTrack('/maps/' + m.id)
} else if (t && window.location.pathname !== '/topics/' + t.id) { } else if (t && window.location.pathname !== '/topics/' + t.id) {
Router.navigate('/topics/' + t.id) Router.navigateAndTrack('/topics/' + t.id)
} }
}, 800) }, 800)
}, },