Web analytics you host yourself. The default strict mode is designed to avoid needing a cookie banner (see the privacy page for the conditions). A Hono server for Cloudflare Workers, Vercel, Railway, Bun or Node, storage on D1, Postgres (Supabase) or SQLite, a 4 KB tracker, React bindings and a dashboard you can embed.
It works on a phone too: the toolbar, the summary and the tables adapt to a narrow screen and a display cutout.
The demo also shows how each privacy mode works and a shop wired up with the React bindings.
- Strict mode by default. The tracker stores no identifier on the visitor's device and no IP address is kept. The visitor id is a pseudonymous hash of IP, user agent and site, salted with a random value that is removed from the live database once the next month starts. Do Not Track visitors are still counted, in strict mode. Strict mode is designed to avoid needing consent, which is not legal advice.
- Two more modes when you need them.
enrichedadds a per-tab id after the visitor consents.persistentuses first-party cookies like most analytics tools do, and should be treated as needing consent in the EU. - Revenue. A payments API with refunds, optional Stripe, Dodo, Lemon Squeezy, Paddle, Polar, Razorpay, Creem and Gumroad webhook adapters, and attribution to the visit that brought the buyer.
- Goals, funnels, campaigns, realtime, JSON and CSV export, retention, share links (read-only, named, with expiry and revoke), notes on charts, CSV and PNG export.
- Framework guides. Mount the server in Next.js, Express, Nuxt, SvelteKit, Astro or Cloudflare Pages, and fix common setup problems with the troubleshooting page.
- A Mac menu bar app. Visitors online next to an icon, today's numbers and a chart one click away, for one or several sites, read with a revocable share link. Install it with
npx analytik menubar; see the guide. - Bring your history. Import the visits and events of Umami, Simple Analytics, Matomo, GoatCounter, Google Analytics 4 or PostHog from Settings or with
analytik import. A repeated import adds nothing, and an import can be removed without touching what Analytik tracked. - One server, three databases. It runs on D1, Postgres and SQLite, and the tests run every case against each of them.
bun add analytik hono
Visitors online next to an icon in the menu bar, today's numbers and a chart one click away, for one or several sites. It reads with a revocable share link and needs macOS 14 or later.
npx analytik menubarOr download the zip from the releases. More in the guide.
import { createAnalytik } from 'analytik/server'
import { d1Storage } from 'analytik/storage/d1'
interface Env {
DB: Parameters<typeof d1Storage>[0]
ADMIN_PASSWORD: string
SESSION_SECRET: string
}
export default {
fetch(request: Request, env: Env) {
const { app } = createAnalytik({
storage: d1Storage(env.DB),
admin: { password: env.ADMIN_PASSWORD, secret: env.SESSION_SECRET },
})
return app.fetch(request, env)
},
}Then add the tracker to your site:
<script defer src="https://analytics.example.com/js/analytik.js" data-site="my-site" data-mode="strict"></script>Track an event or a sale from your own code:
import { createClient } from 'analytik/client'
const analytik = createClient({ site: 'my-site', api: 'https://analytics.example.com/api' })
analytik.track('signup', { plan: 'pro' })
analytik.revenue('purchase', 49.9, { currency: 'EUR', orderId: '1042' })- The tracker (
packages/analytik/src/tracker) sends pageviews, engaged time, outbound clicks and your events toPOST /api/event, using atext/plainbeacon so no preflight is needed. - The server (
packages/analytik/src/server) checks the origin against the site's domain, drops bots, and computes the visitor id with the monthly salt. - Sessions, events and payments land in the storage adapter you chose (
packages/analytik/src/storage). - Payments arrive through
POST /api/v1/paymentsor a provider webhook (packages/analytik/src/adapters) and are matched to the visit that led to them. - The dashboard (
packages/analytik/src/dashboard) reads the admin API. Embed<Dashboard />in your own app or use the one in the demo.
| Where | Storage | Good for |
|---|---|---|
| Cloudflare Workers | D1 | The free plan, no server to run (below) |
| Vercel | Supabase or Neon Postgres | Already hosting your site on Vercel |
| Railway | Railway Postgres | A long-running service with a database |
| Bun or Node | SQLite file | A VPS or a Docker container |
npx analytik@latest create my-statsIt installs the packages, signs you in to Cloudflare, creates the D1 database, deploys a Worker that serves the dashboard, the tracker and the API, and sets the secrets. You get the address and a dashboard password at the end: open it, sign in, add your site and paste the snippet. A small site fits Cloudflare's free plan.
Prefer to click?
Vercel (a function with Postgres)
The Cloudflare button copies the template to your GitHub and deploys it, and asks for two values on its screen: ADMIN_PASSWORD (the password you will sign in with) and SESSION_SECRET (32 or more random characters, openssl rand -hex 32). The Vercel one does the same for a function with Postgres (Supabase or Neon) and asks for the connection string and the two secrets. npx analytik@latest create my-stats --target vercel writes the Vercel project to deploy yourself.
The Worker is a few lines. The dashboard is built into analytik/standalone, so there is no app to build:
import { createAnalytik } from 'analytik/server'
import { withDashboard } from 'analytik/standalone'
import { d1Storage } from 'analytik/storage/d1'
interface Env {
DB: D1Database
ADMIN_PASSWORD: string
SESSION_SECRET: string
}
let handler: ReturnType<typeof withDashboard<[Env, ExecutionContext]>> | undefined
export default {
fetch(request: Request, env: Env, ctx: ExecutionContext) {
handler ??= withDashboard(
createAnalytik({
storage: d1Storage(env.DB),
admin: { password: env.ADMIN_PASSWORD, secret: env.SESSION_SECRET },
}).app,
)
return handler.fetch(request, env, ctx)
},
}The Cloudflare guide has the manual steps, a custom domain, the free-plan limits and a first-party route for ad blockers. To put the dashboard inside your own React app instead, see embedding the dashboard.
Plausible and Umami are good, mature alternatives if you prefer a bigger project.
Browsers: the tracker targets ES2020, so any evergreen browser. Runtimes: Cloudflare Workers, Bun 1.3+, Node 22.19+, Vercel Functions. The dashboard and React bindings need React 19.
bun install
bun run check # samples, format, lint, typecheck, tests with coverage
bun run dev # the demo app
bun run dev:docs # the docs siteSee CONTRIBUTING.md. Security notes are in SECURITY.md.
|
GitHub Profile Open-source repositories & code |
LoupeKit Tech stack, design tokens, AI code checker |
TextArray Online text transformation tool |
|
AddonHive Addons & integrations hub |
Mobile Games & Apps Android & iOS Applications |
And more More projects, writing & contact |
Country flags are from Circle Flags by HatScripts (MIT), see THIRD_PARTY_NOTICES.md.