Performance & Engineering

Why We Rewrote Web Analytics in Rust and WebAssembly (Wasm)

The fastest analytics tags are the ones your main thread never notices.

BLUF: Traditional analytics tags add long tasks that drag INP. We rebuilt the collector in Rust + Wasm to ship a 1.2 KB script, keep execution off the hot path, and capture only privacy-safe signals.

rust web analyticswebassembly performancelightweight analytics script
AnonView Founder
AnonView Founder
Founder, Rust Engineer & Data Privacy Expert
Updated January 16, 2025
Key takeaways
  • 1.2 KB collector payload with zero third-party dependencies
  • Daily rotating session hash, no cookies, no raw user agent
  • OHTTP relay isolates collection from storage

The real cost of classic analytics tags

Most analytics tags ship 30-80 KB of JavaScript, execute on page load, and compete with rendering. Every parse, layout, and script task lands on the main thread.

Google replaced FID with INP, so every interaction now counts. A single long task after a click can turn a good page into a failing page.

If your tag runs on every route, it becomes a permanent tax. A fast product still loses if the analytics layer stalls interaction.

Want to see how much your analytics stack costs in interaction latency? Run a 60-second audit and get a before/after INP snapshot.

Run an INP audit

Why Rust + Wasm is the smallest viable collector

Rust gives us predictable performance and memory safety, while WebAssembly keeps the payload tiny and the execution sandboxed. Together they make a collector that behaves like a system component, not a marketing script.

The goal is not just size. It is deterministic execution: no dynamic imports, no third-party dependencies, and a tight event loop that yields fast.

Collector footprint vs. legacy tags

We benchmarked the collector weight and execution footprint against traditional analytics tags.

Payload
1.2 KB
compressed collector
Parse time
0.4 ms
median on mid-tier device
Main-thread cost
< 3 ms
per navigation
anonview.loader.tsts
import { initCollector } from "@anonview/ghost"
const collector = await initCollector({
relayUrl: process.env.NEXT_PUBLIC_ANONVIEW_RELAY_URL,
siteId: process.env.NEXT_PUBLIC_ANONVIEW_SITE_ID,
sessionRotationHours: 24,
})
collector.track("page_view", {
path: "/pricing",
intent: "conversion",
})

Privacy by design, not by policy

The collector never stores IPs, cookies, or raw user-agent strings. Event metadata is truncated and URL parameters are stripped before they ever leave the browser.

Session identity is ephemeral by design. A daily rotation keeps the data useful for short-term analytics while preventing long-term tracking.

This means your data team gets conversion signals without inheriting data minimization risk.

The relay architecture that isolates collection from storage

Events pass through an OHTTP relay that strips transport metadata and adds only safe relay headers. Storage never sees the original client context.

This separation keeps governance clean. You can scale ClickHouse independently, and you can rotate relay keys without touching the collector.

We wanted an analytics stack that behaves like security infrastructure: minimal footprint, zero PII, and strong isolation boundaries.

-- AnonView Engineering

Migration in three steps

  • Shadow the existing tag for one week and compare INP deltas on high-traffic pages.
  • Flip primary collection to AnonView and keep the old tag for backup sampling.
  • Remove legacy scripts once the conversion funnel matches within accepted variance.

Frequently Asked Questions

Does the 1.2 KB script limit data fidelity?

No. The collector focuses on semantic events and safe metadata, so you still get funnels, conversion intent, and traffic quality without heavy payloads.

Can we use AnonView without cookies?

Yes. The session hash rotates daily and does not require any client-side storage or cookies.

How does this affect INP?

Reducing script weight and main-thread work removes long tasks that normally delay interactions, improving INP on core flows.

Loved this deep-dive on performance? AnonView keeps analytics invisible.

The lightest privacy-first analytics stack with human verification, sovereign storage, and an AI analyst that never sleeps.

Book a demo
AnonView Founder
AnonView Founder
Founder, Rust Engineer & Data Privacy Expert

Founder of AnonView, focused on privacy-first analytics and Rust performance engineering.