track pageloads with google analytics. fixes #1012 (#1048)

* track pageloads with google analytics. fixes #1012

* Update Router.js
This commit is contained in:
Connor Turland 2017-01-25 20:57:34 -08:00 committed by GitHub
parent db81962c91
commit 6e913efbae
2 changed files with 9 additions and 4 deletions

View file

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

View file

@ -206,9 +206,9 @@ const Visualize = {
var t = Active.Topic
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) {
Router.navigate('/topics/' + t.id)
Router.navigateAndTrack('/topics/' + t.id)
}
}, 800)
},