src/app.html · open source (MIT) · ask in plain English

Add analytics to SvelteKit.

SvelteKit ships fast, hydrated pages across SSR and CSR, so your analytics has to catch navigations the router does without a full reload. smolanalytics drops in as two script tags in src/app.html, autocaptures pageviews, clicks, scroll and JS errors with zero code, and lets you ask your numbers in plain English from the dashboard or your editor.

src/app.html
<!-- src/app.html, inside <head> ... %sveltekit.head% lives here too -->
<head>
  <!-- ...existing head... -->
  <script src="https://YOUR-INSTANCE/sdk.js"></script>
  <script>smolanalytics.init("WRITE_KEY", { host: "https://YOUR-INSTANCE" })</script>
</head>

src/app.html is the one HTML shell every SvelteKit route renders into, so both tags load once and client-side navigations get captured automatically.

how do I add analytics to sveltekit?

SvelteKit ships fast, hydrated pages across SSR and CSR, so your analytics has to catch navigations the router does without a full reload. smolanalytics drops in as two script tags in src/app.html, autocaptures pageviews, clicks, scroll and JS errors with zero code, and lets you ask your numbers in plain English from the dashboard or your editor.

In SvelteKit the thing worth measuring is client-side navigation, form actions, and the load-function boundary between server and client. Autocapture handles the pageviews and clicks for free, so start by watching which routes people actually reach and where rage or dead clicks pile up. For the moments that matter, call smolanalytics.track("signup", { plan: "pro" }) inside your form action or an onMount, and identify(userId) once the session resolves.

It fits SvelteKit because there is no build step or adapter to fight. The two tags sit in src/app.html and load on every route whether it rendered on the server or the client. It is one open-source Go binary you can self-host free or run hosted from 29 dollars a month, cookieless so you skip the consent banner, and every answer it gives you is a deterministic report a CI test proves it can't hallucinate.

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 SvelteKit 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 SvelteKit?
SvelteKit ships fast, hydrated pages across SSR and CSR, so your analytics has to catch navigations the router does without a full reload. smolanalytics drops in as two script tags in src/app.html, autocaptures pageviews, clicks, scroll and JS errors with zero code, and lets you ask your numbers in plain English from the dashboard or your editor.
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