Merge pull request #59 from coolhihi/master

Fixed: error when using pjax with google analytics
This commit is contained in:
Maxime Thirouin
2016-03-12 07:09:55 +01:00

View File

@@ -7,7 +7,7 @@ module.exports = function(options){
this.options.switches = this.options.switches || {} this.options.switches = this.options.switches || {}
this.options.switchesOptions = this.options.switchesOptions || {} this.options.switchesOptions = this.options.switchesOptions || {}
this.options.history = this.options.history || true this.options.history = this.options.history || true
this.options.analytics = this.options.analytics || function(options) { this.options.analytics = this.options.analytics || function() {
// options.backward or options.foward can be true or undefined // options.backward or options.foward can be true or undefined
// by default, we do track back/foward hit // by default, we do track back/foward hit
// https://productforums.google.com/forum/#!topic/analytics/WVwMDjLhXYk // https://productforums.google.com/forum/#!topic/analytics/WVwMDjLhXYk
@@ -15,7 +15,7 @@ module.exports = function(options){
_gaq.push(["_trackPageview"]) _gaq.push(["_trackPageview"])
} }
if (window.ga) { if (window.ga) {
ga("send", "pageview", {page: options.url, title: options.title}) ga("send", "pageview", {page: location.pathname, title: document.title})
} }
} }
this.options.scrollTo = (typeof this.options.scrollTo === 'undefined') ? 0 : this.options.scrollTo; this.options.scrollTo = (typeof this.options.scrollTo === 'undefined') ? 0 : this.options.scrollTo;