src/root.tsx · open source (MIT) · ask in plain English

Add analytics to Qwik.

Qwik is resumable and ships near-zero JS until you interact, so bolting on a heavy analytics SDK defeats the point. smolanalytics is two small script tags in the head of src/root.tsx, autocapturing pageviews, clicks, scroll and JS errors with no code. You ask your numbers in plain English instead of hand-instrumenting a lazily-hydrated app.

src/root.tsx
// src/root.tsx, inside the <head> of the Root component
<head>
  <meta charSet="utf-8" />
  <RouterHead />
  <script src="https://YOUR-INSTANCE/sdk.js"></script>
  <script
    dangerouslySetInnerHTML={`smolanalytics.init("WRITE_KEY", { host: "https://YOUR-INSTANCE" })`}
  ></script>
</head>

src/root.tsx holds the document head for every Qwik City route. Qwik's dangerouslySetInnerHTML takes the string directly, so the init runs on load.

how do I add analytics to qwik?

Qwik is resumable and ships near-zero JS until you interact, so bolting on a heavy analytics SDK defeats the point. smolanalytics is two small script tags in the head of src/root.tsx, autocapturing pageviews, clicks, scroll and JS errors with no code. You ask your numbers in plain English instead of hand-instrumenting a lazily-hydrated app.

Qwik's whole pitch is resumability, so the metric that matters most is whether interactions actually fire on those lazily-loaded chunks. Autocapture gives you clicks with the full element chain, scroll depth, and JS errors from code that only downloads on demand, which is exactly where a resumable app tends to hide breakage. For business events, call smolanalytics.track("signup") inside your event handler and identify(userId) after login.

It fits Qwik because it is a plain script tag, not a framework integration that would force eager hydration. It loads once from root.tsx and stays out of the resume path. It is one open-source Go binary, self-host free or hosted from 29 dollars a month, cookieless with no consent banner, and every report is deterministic and proven by a CI test not to be hallucinated.

Honest pricing: 14-day full trial, no credit card. Then Solo $29/mo, never metered on seats or sites. Overage is $5/million with an emailed receipt, the dashboard never locks, and self-hosting the single Go binary is free forever (MIT).

Add analytics to Qwik tonight.

One snippet, or one endpoint. Tomorrow morning the verdict tells you which part of the funnel to fix.

questions

How do I add analytics to Qwik?
Qwik is resumable and ships near-zero JS until you interact, so bolting on a heavy analytics SDK defeats the point. smolanalytics is two small script tags in the head of src/root.tsx, autocapturing pageviews, clicks, scroll and JS errors with no code. You ask your numbers in plain English instead of hand-instrumenting a lazily-hydrated app.
Do I need a cookie banner?
Not in cookieless mode. smolanalytics can run without storing anything on the device, so there is no consent banner to add. You still get visitors, referrers, funnels, retention, and paths, and AI-assistant referrals (chatgpt.com, claude.ai, perplexity.ai) show up as their own channel.
Is it enough for a real product, or just page counts?
It does funnels, retention, paths, cohorts, and a daily verdict on what to fix, from the same events, and you ask it in plain English. It deliberately skips session replay, feature flags, and experiments. If you want a straight answer on what to fix, that you own and can self-host free, it fits.

keep reading