Cleanup default analytics function #113

Merged
robinnorth merged 4 commits from cleanup/analytics into master 2018-01-25 02:51:00 -05:00
2 changed files with 3 additions and 7 deletions
Showing only changes of commit f559ca2914 - Show all commits

View File

@@ -272,7 +272,9 @@ Pjax.prototype = {
// Fire Events
trigger(document,"pjax:complete pjax:success", state.options)
state.options.analytics()
if (typeof state.options.analytics === "function") {
state.options.analytics()
}
if (state.options.history) {
// First parse url and check for hash to override scroll

View File

@@ -10,9 +10,6 @@ module.exports = function(options) {
this.options.switchesOptions = this.options.switchesOptions || {}
this.options.history = this.options.history || true
this.options.analytics = this.options.analytics || function() {
// options.backward or options.foward can be true or undefined
// by default, we do track back/foward hit
// https://productforums.google.com/forum/#!topic/analytics/WVwMDjLhXYk
if (window._gaq) {
_gaq.push(["_trackPageview"])
}
@@ -36,7 +33,4 @@ module.exports = function(options) {
if (!this.options.switches.body) {
this.options.switches.body = defaultSwitches.switchElementsAlt
}
if (typeof options.analytics !== "function") {
options.analytics = function() {}
}
}