Skip to content

Fix docs Amplitude page views missing path property#21374

Merged
aaazzam merged 1 commit intomainfrom
fix/docs-amplitude-page-view-path
Mar 31, 2026
Merged

Fix docs Amplitude page views missing path property#21374
aaazzam merged 1 commit intomainfrom
fix/docs-amplitude-page-view-path

Conversation

@aaazzam
Copy link
Copy Markdown
Collaborator

@aaazzam aaazzam commented Mar 31, 2026

Summary

  • Disable defaultTracking.pageViews — Amplitude's auto-tracked Page View: Docs New events don't include the custom path property, producing the 71% of events with path = (none). Replaced with the manual trackPageView() which always sets path: window.location.pathname.
  • Fire trackPageView on every SPA navigation via observeRouteChanges() instead of only once on init via setTimeout.
  • Refactor observeRouteChanges to support multiple callbacks so both Unify and Amplitude can listen for route changes.
  • Fix window.hrefwindow.location.href (window.href is undefined).

🤖 Generated with Claude Code

Two issues caused most Page View: Docs New events to lack the path property:

1. Amplitude's defaultTracking.pageViews fired auto-tracked events on every
   SPA navigation without the custom path property, while the manual
   trackPageView() (which sets path) only ran once on init.

2. observeRouteChanges() only supported a single callback, so it couldn't
   be reused for both Unify and Amplitude tracking.

Changes:
- Disable defaultTracking.pageViews (set to false)
- Hook trackPageView into observeRouteChanges so it fires on every route change
- Refactor observeRouteChanges to support multiple callbacks
- Fix window.href -> window.location.href (was always undefined)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mintlify
Copy link
Copy Markdown

mintlify bot commented Mar 31, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Prefect 🟢 Ready View Preview Mar 31, 2026, 5:30 PM

@aaazzam aaazzam merged commit 6d471ce into main Mar 31, 2026
15 checks passed
@aaazzam aaazzam deleted the fix/docs-amplitude-page-view-path branch March 31, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants