a route or middleware · open source (MIT) · ask in plain English

Add analytics to Express.

smolanalytics tracks an Express app two ways: server-side events posted with fetch from your routes and middleware, and a browser snippet for any HTML you render that autocaptures pageviews and clicks. Both share one write key. You query the data in plain English and get deterministic, un-hallucinatable reports.

a route or middleware
async function track(name, distinctId, properties) {
  await fetch("https://YOUR-INSTANCE/v1/events", {
    method: "POST",
    headers: {
      Authorization: "Bearer WRITE_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ name, distinct_id: distinctId, properties }),
  });
}

app.post("/signup", async (req, res) => {
  // ... create the user ...
  track("signup", user.id, { plan: "pro" }); // fire and forget
  res.json({ ok: true });
});

// Web autocapture (if you serve HTML): two tags in your template <head>
// <script src="https://YOUR-INSTANCE/sdk.js"></script>
// <script>smolanalytics.init("WRITE_KEY", { host: "https://YOUR-INSTANCE" })</script>

call track() without awaiting so it never blocks the response. batch several events into one array body under load.

how do I add analytics to express?

smolanalytics tracks an Express app two ways: server-side events posted with fetch from your routes and middleware, and a browser snippet for any HTML you render that autocaptures pageviews and clicks. Both share one write key. You query the data in plain English and get deterministic, un-hallucinatable reports.

Express gives you a natural seam in middleware and route handlers. One fetch to /v1/events with a Bearer key, a distinct_id and a properties object, called fire-and-forget so the response goes out immediately. Send an array of events to batch. If your Express app also renders HTML with EJS, Pug or Handlebars, the two script tags in the template add full browser autocapture on the same key.

The collector is a single Go binary you self-host (MIT) or run hosted from $29/mo. Answers are deterministic reports with a CI test that proves they can't be fabricated, so the number you show a customer holds up. Ask it in plain English from the dashboard bar or from your editor over MCP.

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 Express 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 Express?
smolanalytics tracks an Express app two ways: server-side events posted with fetch from your routes and middleware, and a browser snippet for any HTML you render that autocaptures pageviews and clicks. Both share one write key. You query the data in plain English and get deterministic, un-hallucinatable reports.
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