Capture pageviews on client-side navigation - #184
Open
plusminushalf wants to merge 1 commit into
Open
plusminushalf wants to merge 1 commit into
plusminushalf wants to merge 1 commit into
Conversation
Vocs routes on the client, so PostHog's default page-load capture only ever records the page a session lands on. Pageviews per session dropped from ~2.6 to ~1.1 in the week of 14 June and have stayed there since; sessions over the same period never moved, and the posthog-js versions reporting before and after that week do not overlap. Docs traffic did not fall — roughly 60% of pageviews simply stopped being recorded. Set capture_pageview explicitly so the behaviour no longer depends on whichever array.js the CDN happens to serve, which is what changed underneath us. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H92LZ24QZsspCiQgLjdEYB
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Docs pageviews look like they fell off a cliff in mid-June. They didn't — we stopped recording most of them.
Three things line up:
Vocs routes on the client, and PostHog's default
capture_pageviewfires on page load only.array.jsis loaded unpinned from the CDN, so the version — and with it the effective behaviour — rolled forward without a deploy on our side.Net effect: roughly 60% of docs pageviews have been missing for three months, and the "traffic drop" everyone has been looking at isn't real.
The fix
'history_change'is PostHog's documented setting for single-page apps — it records route changes via the History API instead of only page loads. Setting it explicitly also means the behaviour stops depending on whicheverarray.jsthe CDN serves, which is what changed underneath us in the first place.On the root cause
The data cannot distinguish between two explanations: PostHog's default changing in the newer SDK, or Vocs moving to client-side routing in the same dependency bump. They happened together and produce an identical signature. This fix is correct for either, but it's worth being clear that the mechanism is one of the two rather than confirmed as the first.
Verification
Cannot be confirmed before this deploys — it depends on the real SDK on the real site. After merge, expect pageviews per session to return to roughly 2.5 within a day. Query to check:
Worth knowing when reading historical numbers: June–September docs pageviews are not comparable to anything before 14 June. Sessions are the reliable series across that boundary.
🤖 Generated with Claude Code
https://claude.ai/code/session_01H92LZ24QZsspCiQgLjdEYB