Skip to content

Count the page a visitor actually arrives on - #169

Merged
xuelink merged 1 commit into
mainfrom
claude/count-the-first-page
Sep 11, 2026
Merged

Count the page a visitor actually arrives on#169
xuelink merged 1 commit into
mainfrom
claude/count-the-first-page

Conversation

@xuelink

@xuelink xuelink commented Sep 11, 2026

Copy link
Copy Markdown
Member

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' turns capture_pageview into 'history_change'. That mode is exactly what it says: the SDK wraps pushState, replaceState and popstate and 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:

requests to /relay
cold load of langx.io/ 0
clicking an internal link 1
explicit capture('$pageview') after init 1

So init is 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_mode gains 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

`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>
@xuelink
xuelink merged commit cb6114b into main Sep 11, 2026
1 check passed
@xuelink
xuelink deleted the claude/count-the-first-page branch September 11, 2026 01:59
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