Skip to content

Commit

Permalink
fix: analytics bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Feb 10, 2022
1 parent 9f75036 commit 639749a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/plugins/analytics/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default (function () {
return null
}

// Workaround until https://github.com/facebook/docusaurus/issues/3399 is fixed
let lastLocation = window.location.pathname
return {
onRouteUpdate({ location }) {
if (typeof window.gtag !== 'function') {
Expand All @@ -21,6 +23,12 @@ export default (function () {
const pagePath = location
? location.pathname + location.search + location.hash
: undefined

if (lastLocation === location.pathname) {
return
}
lastLocation = location.pathname

window.gtag('config', 'UA-71865250-1', {
page_path: pagePath
})
Expand Down
1 change: 1 addition & 0 deletions src/plugins/docusaurus-plugin-matamo/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default (function () {
return null
}

// Workaround until https://github.com/facebook/docusaurus/issues/3399 is fixed
let lastLocation = window.location.pathname
return {
onRouteUpdate({ location }) {
Expand Down

0 comments on commit 639749a

Please sign in to comment.