X Tutup
The Wayback Machine - https://web.archive.org/web/20221217083211/https://github.com/docsifyjs/docsify/issues/1374
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On routerMode: "history", Google Analytics plugin may send wrong page value #1374

Open
rizdaprasetya opened this issue Sep 14, 2020 · 0 comments

Comments

@rizdaprasetya
Copy link
Contributor

rizdaprasetya commented Sep 14, 2020

Bug Report

Wrong page path/url value being sent by Docsify's Google Analytics plugins if config used is routerMode: "history".

Steps to reproduce

run/deploy docsify with the following config of history routerMode:

window.$docsify = {
  routerMode: 'history'
};

With Google Analytics plugin enabled

Check the Codesandbox example on the bottom, to see some demo.

What is current behaviour

Due to this line:

window.ga('set', 'page', location.hash);
window.ga('send', 'pageview');

On history routerMode, the location.hash value is always empty string "".
No matter which page visitor open, the value being sent as page is always empty string.

What is the expected behaviour

On history routerMode, the value of third param of window.ga('set', 'page', currentPageValue); should be the proper path of the current page opened by visitor.

Maybe first check what is the value of routerMode, then determine wether to use location.hash or not.

Other relevant information

ref to Google analytics for SPA guide:
https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications

  • Your OS: Mac OS, any OS really.
  • Node.js version: any
  • npm/yarn version: any
  • Browser version: any
  • Docsify version: any
  • Docsify plugins: Google Analytics

Please create a reproducible sandbox

Edit 307qqv236

Mention the docsify version in which this bug was not present (if any)

none

Anyway thanks for this amazing project! 🚀

@project-bot project-bot bot added this to Needs Review in Triage Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Triage
  
Needs Review
Development

No branches or pull requests

2 participants
X Tutup