Live analytics for Django, FastAPI and Flask
Live analytics for Python apps: middleware for Django, FastAPI, Starlette and Flask sends sign-ins, crawler visits, 404s, errors, response times and your events.
Install
pip install mettr
Python 3.10 or later, no dependencies.
Django
INSTALLED_APPS = [..., "mettr.django"] MIDDLEWARE = [..., "mettr.django.MettrMiddleware"]
{% load mettr %}
<head>{% mettr_script %}</head>
FastAPI and Starlette
app.add_middleware(MettrMiddleware, mettr=Mettr())
Flask
mettr = MettrFlask(app)
What you get without writing code
- Page views and who is online, from the browser script, served from
/_liveon your own domain, so ad blockers mostly let it through. - Sign-ins and sign-ups in Django, as
loginandsignup; staff (is_staff) send nothing. - Crawler visits, with their page and status: only your server sees them.
- 404s and exceptions, the latter by class only, never the message.
- Response times of one request in twenty, by route.
Sync and async views alike. Events go from a background thread, never in the request's way.
Your own events
mettr.event("signup", {"plan": "pro"}, Visitor(user_id="42"))
Revenue from your own billing
Stripe, Paddle and Polar are read by mettr itself. Billing of your own? mettr.subscription() sends each subscription as it changes, and MRR, churn and revenue by source follow.
Open source
mettr is MIT licensed, on GitHub and PyPI. The full guide.
Read on
Python
The mettr package sends a Django, FastAPI, Starlette or Flask app's events, crawler visits, 404s, errors and response times, with no dependencies.
Product events
Send your product's own events from the server, with the user and their properties: sign-ups, upgrades, exports. Live on the dashboard, in funnels and breakdowns, beyond the reach of ad blockers.
Stripe revenue analytics
Connect Stripe with a read-only key and see MRR, ARR, churn and every movement beside your traffic, with each subscription credited to the source that brought its customer.
See your site live in two minutes
Free for one site. No card, no cookie banner