Funnel visibility: landing-page + traffic-source metrics#67
Merged
Conversation
…k land/come from)
The event funnel measured what visitors DID but not where they LANDED or came
FROM — so a traffic spike with 0 signups was undiagnosable. Add two KV daily
dimensions written by a fire-and-forget GET middleware:
land:<page>:<day> — arrival page bucket (home/drops/guides/leaderboard/u/...)
ref:<source>:<day> — utm_source/Referer host, with bot UA → "bot" so we can
separate real humans from crawlers in the visitor count.
Surfaced in GET /api/v1/admin/metrics (landing/sources rollups) and readable
straight from KV. Pure bucketers covered by metrics_dims.test.ts.
Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Why
We have a traffic spike (~25k page views) with ~0 signups and couldn't tell where the traffic lands or comes from — the existing funnel counters only measured actions (u_view, checkout_started, paid), not arrival page or referrer. Diagnosing capture was blind.
What
A fire-and-forget GET middleware records two KV daily dimensions:
land:<page>:<day>— arrival-page bucket (home/drops/guides/leaderboard/grade/u/pricing/…)ref:<source>:<day>—utm_source/sourcetag → elseRefererhost (mapped to google/bing/reddit/x/tiktok/youtube/chatgpt/… or eTLD+1) → bot UA →botso the crawler share of the visitor number is separable.Surfaced in
GET /api/v1/admin/metricsaslanding+sourcesrollups, and readable straight from theland:/ref:KV counters.Safety
trackViewno-ops on assets/API and can never throw into the request path.metrics_dims.test.ts, 7 cases). Full suite 255+7 green, typecheck clean.🤖 Generated with Claude Code