* track pageloads with google analytics. fixes #1012 * Update Router.js
This commit is contained in:
parent
db81962c91
commit
6e913efbae
2 changed files with 9 additions and 4 deletions
|
@ -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)
|
||||||
|
window.ga && window.ga('send', 'pageview', location.pathname, {title: document.title})
|
||||||
|
}
|
||||||
|
|
||||||
Router.intercept = function(evt) {
|
Router.intercept = function(evt) {
|
||||||
var segments
|
var segments
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue