Server events
Flask
Send server-side conversions from Flask — forwarded from the request, credited to the real visitor.
Fire a server-side conversion from a Flask route, crediting the real visitor:
import requestsfrom flask import Flask, requestapp = Flask(__name__)@app.post("/checkout/success")def checkout_success(): # Prefer the FIRST X-Forwarded-For entry (the real client); else remote_addr. forwarded = request.headers.get("X-Forwarded-For", "") ip = forwarded.split(",")[0].strip() if forwarded else request.remote_addr requests.post( "https://datalook.app/event", headers={ "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json", }, json={ "event_name": "success", "name": "signup", "page_path": request.path, "ip": ip, "user_agent": request.headers.get("User-Agent", ""), }, timeout=5, ) return {"ok": True}Note
Flask exposes the path as request.path (not request.url); behind a proxy you must read the first X-Forwarded-For entry, since request.remote_addr is the proxy.
How it’s credited
This reads the visitor’s IP and User-Agent from the request and forwards them, so the conversion lands on the real visitor — device, country, and source included. No
identify(), no ids, no cookie. Get an API key in the dashboard under Track it from your server; see the overview for the concepts and the webhook path.