diff --git a/src/plugins/analytics/analytics.js b/src/plugins/analytics/analytics.js index 1f1ed24ed6..2e787f865c 100644 --- a/src/plugins/analytics/analytics.js +++ b/src/plugins/analytics/analytics.js @@ -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') { @@ -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 }) diff --git a/src/plugins/docusaurus-plugin-matamo/analytics.js b/src/plugins/docusaurus-plugin-matamo/analytics.js index e0dc039638..d446b89814 100644 --- a/src/plugins/docusaurus-plugin-matamo/analytics.js +++ b/src/plugins/docusaurus-plugin-matamo/analytics.js @@ -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 }) {