Django projects tend to own their whole stack: templates, views, billing. That makes revenue attribution straightforward, because your own view creates the checkout and can say which visitor it belongs to.
What you get
- Every page that extends your base template, tracked with its source, campaign, country and device.
- The admin left out. Django's admin uses its own templates, so it isn't tracked, which is usually what you want.
- Revenue credited to visits from checkouts your views create.
- Payments from your own billing sent from Python with the Payments API.
How to install it
- Open the base template your other templates name in
{% extends "base.html" %}, oftentemplates/base.html. - Paste the snippet before
</head>and deploy. - Templates that don't extend the base, such as a custom error page, need the snippet too.
Template inheritance is described in Django's template language docs (opens in a new tab). If your app sends a Content Security Policy, allow the Reveata script and endpoint (Content Security Policy).
Linking payments to visits
- Connect your payment provider in Reveata.
- In the template with your buy button, add two hidden fields,
reveata_visitor_idandreveata_session_id, filled fromwindow.reveata.metadata()when the form is sent. Keep{% csrf_token %}inside the form. - In the view that creates the Stripe Checkout Session, copy them into
metadata:
session = stripe.checkout.Session.create(
mode="subscription",
line_items=[{"price": price_id, "quantity": 1}],
success_url="https://example.com/thanks",
metadata={k: v for k, v in {
"reveata_visitor_id": request.POST.get("reveata_visitor_id"),
"reveata_session_id": request.POST.get("reveata_session_id"),
}.items() if v},
)The view can also read Reveata's _dt_v and _dt_s cookies from request.COOKIES. Other providers take the same keys in their custom data (Stripe Checkout attribution). With your own billing, post each payment to the Payments API instead, never both for the same provider.
Serving the script from your own domain
Django usually runs behind NGINX or Caddy, which can proxy the script and events with the visitor's address and your proxy secret (NGINX, Caddy). Without server access, the managed proxy needs one DNS record.