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.
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.