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

Duplicate Google Analytics Events Triggered on Docusaurus Documentation Site #10568

Open
5 of 7 tasks
kaushal0107 opened this issue Oct 9, 2024 · 0 comments
Open
5 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers

Comments

@kaushal0107
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

We are experiencing an issue where duplicate Google Analytics (GA) events are being sent when users visit our documentation site built using Docusaurus. This results in two page view counts for each user session in our GA reports.

Our main website is hosted at www.test.com and the documentation is available at www.test.com/docs. We have configured Google Analytics for the main website using a single gtag ID (G-test). We also configured the Docusaurus documentation site using the same gtag ID via Docusaurus' @docusaurus/plugin-google-gtag.

Whenever we access the documentation site (www.test.com/docs), we observe two collect network calls being made to Google Analytics, which results in inflated user visit counts.

Reproducible demo

No response

Steps to reproduce

  1. Create a new Docusaurus documentation site (e.g., my-docs-site).
  2. Pick a gtag ID from one of your existing websites that already has Google Analytics configured.
  3. Use this gtag ID in the Docusaurus setup (@docusaurus/plugin-google-gtag).
  4. Open the documentation site in the browser and navigate through pages.
  5. Open the browser’s developer tools (Network tab).
  6. Observe that two collect calls are made to Google Analytics for every user action.
  7. Check Google Analytics and notice that two page view events are logged for every visit to the documentation.

Expected behavior

  • Only one collect call should be made when visiting the documentation.
  • GA should only count one user visit per page load.

Actual behavior

  • Two collect calls are triggered for each page visit and navigation between pages on the documentation site, causing GA to log two user visits for every single page load or navigation event.

Your environment

  • Docusaurus version used: 3.5.2
  • Environment name: All browser
  • Operating system: Windows/Linux/MacOS

Self-service

  • I'd be willing to fix this bug myself.
@kaushal0107 kaushal0107 added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant