Skip to content

Fire Docs Visited Plausible event on every docs page view#308

Open
lencioni wants to merge 1 commit into
mainfrom
plausible-docs-visited
Open

Fire Docs Visited Plausible event on every docs page view#308
lencioni wants to merge 1 commit into
mainfrom
plausible-docs-visited

Conversation

@lencioni
Copy link
Copy Markdown
Contributor

Summary

Companion to happo/happo-view#3812 for HAP-852.

Fires a Docs Visited Plausible custom event whenever the user lands on or navigates to a page under docs.happo.io. This lets us use docs visits as a top-of-funnel goal in Plausible (alongside Pricing Viewed, Trial Signup, etc.) so we can measure conversion rate by source rather than raw visits.

Implementation

  • Adds the onRouteDidUpdate client-module lifecycle hook so the event fires on both initial load and client-side route changes.
  • Skips firing on hash/query-only changes (same pathname as previous).
  • Sends path as a Plausible custom prop so we can break the event down by section of the docs.
  • The Plausible tracker library is still lazy-loaded once and init() is called only once; subsequent navigations reuse the cached module via a memoized getTracker() promise.

Test plan

  • Build the site locally and confirm the event fires in Plausible's "test events" view on initial load and on client navigations
  • Confirm no extra event fires on hash navigations within the same page

Made with Cursor

Adds an onRouteDidUpdate client lifecycle hook that fires the
"Docs Visited" custom event whenever the user lands on or navigates
to a page under docs.happo.io. This lets us use docs visits as a
top-of-funnel goal in Plausible (HAP-852).

The tracker library is still lazy-loaded once and initialized only
once; subsequent route changes reuse the cached module.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lencioni lencioni requested a review from trotzig as a code owner May 13, 2026 21:42
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.

1 participant