Stop the analytics tracker hijacking every link but Home

Performancekamo-marketing
Shipped
August 19, 2026 at 4:19 PM UTC
Author
Kamo
Commit
f321857

Every page except the homepage took seconds to open, and the reason was never in this app's own navigation path: the server prerenders, prefetch payloads are complete (78 chunk refs, ~57 KB, 68 ms), every internal href is a locale-aware <Link>, and the deployed probe measured soft navigations INTO the homepage at 111-194 ms. What the probe never recorded was a soft navigation into anything else — seven consecutive clicks came back as [navload], i.e. cold document loads. analytics does that. Its tracker installs a capture-phase click listener and, for any <a> carrying data-analytics-event, runs e.preventDefault() // the <Link> client navigation is cancelled await track(...) // POST /api/send location.href = href // full document load so the attribute silently converts a client navigation into "wait for analytics, then hard reload". Here the beacon blocks on a geo-IP lookup and takes 1.5-8 s (fixed separately in kamo-analytics), on top of which the browser then threw away the page and re-parsed ~1 MB of JS. The Home link and the logo were the only two internal links in the header without the attribute. That is the whole of "every page except the home page". Replaces all 119 data-analytics-event* attributes with trackEvent() from app/lib/analytics.ts, called in onClick: same event name, same payload, and the tracker's own send is keepalive:true, so a beacon fired on the way off-site still completes. Nothing is lost, including the outbound CTAs to register/login, which had been waiting on the round trip before leaving the page. Guarded by **************** (prebuild, so the image build and therefore the deploy fail on a regression). The ban is total rather than anchors-only: on a <button> the attribute is harmless right up until someone turns it into a <Link>, and the failure is invisible in markup, types and lint because the behaviour is injected at runtime by a third-party script.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing