Server events
Django
Send server-side conversions from Django — forwarded from the request, credited to the real visitor.
Record a server-side conversion from a Django view:
import requestsfrom django.http import HttpResponsedef checkout_success(request): # X-Forwarded-For may be a chain ("client, proxy1, ..."); the first entry # is the real visitor. Fall back to REMOTE_ADDR when there's no proxy. forwarded = request.META.get("HTTP_X_FORWARDED_FOR", "") ip = forwarded.split(",")[0].strip() if forwarded else request.META.get("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 HttpResponse("Thanks for signing up.")Note
Django's request.path includes the leading slash and excludes the query string; read the User-Agent via request.headers.get("User-Agent") (request.headers is case-insensitive).
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.