your route handler · open source (MIT) · ask in plain English

Add analytics to Flask.

smolanalytics fits a Flask app in two spots: server-side events posted from your route handlers, and a browser snippet in your Jinja layout that autocaptures pageviews and clicks. Both use one write key. You ask your numbers in plain English and get deterministic, un-hallucinatable reports.

your route handler
import requests

@app.post("/signup")
def signup():
    # ... create the user ...
    requests.post(
        "https://YOUR-INSTANCE/v1/events",
        headers={"Authorization": "Bearer WRITE_KEY"},
        json={"name": "signup", "distinct_id": str(user.id), "properties": {"plan": "pro"}},
        timeout=2,
    )
    return redirect("/app")

# Web autocapture: put these two tags in templates/layout.html <head>
# <script src="https://YOUR-INSTANCE/sdk.js"></script>
# <script>smolanalytics.init("WRITE_KEY", { host: "https://YOUR-INSTANCE" })</script>

in a small Flask app a synchronous POST with a short timeout is fine. for volume, batch events or fire from a background thread.

how do I add analytics to flask?

smolanalytics fits a Flask app in two spots: server-side events posted from your route handlers, and a browser snippet in your Jinja layout that autocaptures pageviews and clicks. Both use one write key. You ask your numbers in plain English and get deterministic, un-hallucinatable reports.

Flask stays out of your way, and so does this. The events that matter (a signup, a payment, a job finishing) get one requests.post to /v1/events with a Bearer key, a distinct_id and a properties dict. Batch several into a list to save round trips. For anything that happens in the browser, the two script tags in layout.html autocapture pageviews, scroll, dead and rage clicks with zero extra code.

The backend is a single Go binary: self-host it free (MIT) or use hosted from $29/mo. Every answer is a deterministic report backed by a CI test that proves it can't be fabricated, which matters when the number decides something. 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 Flask 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 Flask?
smolanalytics fits a Flask app in two spots: server-side events posted from your route handlers, and a browser snippet in your Jinja layout that autocaptures pageviews and clicks. Both use one write key. You ask your numbers 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