Count the page a visitor actually arrives on - #169
Merged
Conversation
`defaults: '2026-05-30'` sets `capture_pageview: 'history_change'`, and that
mode captures a page view when `pushState`, `replaceState` or `popstate`
changes the path. A visit arriving from outside changes nothing — it is the
first path — so the landing page was never counted. Only internal link clicks
were, which on a marketing site is a small and badly skewed minority of the
traffic.
Measured on the deployed site rather than reasoned about: a cold load makes no
request to the relay at all, clicking an internal link immediately makes one,
and an explicit capture after `init` makes one too. The duplicate this looks
like cannot happen — the history hook only captures when the path, search or
hash differs from the last one it saw.
The comment above `cookieless_mode` gains the half of that setting that lives
outside the repository: the project needs "Cookieless server hash mode" on, or
ingestion drops every event this file produces while answering each request
`{"status":"Ok"}`. It was off, which is why the site had sent nothing at all
since analytics shipped. Switched on in the project on 10 September 2026.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
langx.io has sent nothing to PostHog since analytics shipped on 8 September — not one
$pageview, ever. Two separate faults, one in the project and one here.The project setting (already fixed, no code)
cookieless_mode: 'always'has a documented prerequisite that lives in PostHog rather than in this repo: the project must have Cookieless server hash mode switched on. It was off. Ingestion accepted every request, answered{"status":"Ok"}, and dropped the event. Nothing warns you anywhere.Switched on in project 265343 on 10 September 2026 — and the site's own events started arriving within the minute, which is how it was confirmed.
The landing page (this change)
defaults: '2026-05-30'turnscapture_pageviewinto'history_change'. That mode is exactly what it says: the SDK wrapspushState,replaceStateandpopstateand captures a page view when one of them changes the path. A visit arriving from outside changes nothing — it is the first path — so only internal link clicks were being counted. On a marketing site, most people read one page and leave, so most of the traffic was invisible.Measured on the deployed site, not reasoned about:
/relaylangx.io/capture('$pageview')after initSo
initis followed by one explicit capture. The duplicate this looks like cannot happen: the history hook only captures when path, search or hash differs from the last one it saw.The comment above
cookieless_modegains the project-setting half, so the next person who finds an empty dashboard checks the setting before the code.Checks
npx vite build✅ ·prettier --check✅🤖 Generated with Claude Code