Skip to content

🕷️ Patch tracking element load failure#2417

Open
JFWooten4 wants to merge 1 commit intostellar:mainfrom
JFWooten4:2145-pt-41
Open

🕷️ Patch tracking element load failure#2417
JFWooten4 wants to merge 1 commit intostellar:mainfrom
JFWooten4:2145-pt-41

Conversation

@JFWooten4
Copy link
Copy Markdown
Contributor

Docusaurus does not have a good time right now where there are interruptions between it and the Google Tag Manager. This PR stops the following recurring error (scales with page reloads when it happens):

image

Changes

Adds a runtime guard around Docusaurus’ Google gtag page-view tracking callback. It is often blocked by an ad blocker, delayed, or not loaded yet, that call can crash.

Previously, the plugin assumed window.gtag was always available before sending the page_view event. This patch returns early when window.gtag is not a function, preventing runtime errors in environments where the analytics script is unavailable.

The intent is to keep analytics optional and non-blocking, so page navigation continues safely even when Google tracking cannot run. Hence the page-view guard.

Copilot AI review requested due to automatic review settings April 30, 2026 11:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes Docusaurus’ Google gtag page-view tracking resilient to cases where window.gtag is blocked or not yet loaded (e.g., ad blockers / interrupted GTM), preventing runtime errors during navigation.

Changes:

  • Adds a runtime guard to return early when window.gtag is not a function before sending page_view.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants