DataLook Docs
Install guides

Django

Install DataLook on Django — the plain script tag, or the first-party proxy that beats ad blockers. Both on one page.

Add the tag to your base template.

Add the script to your base template <head>

templates/base.html
<script defer src="https://cdn.datalook.app/s.js" data-site="YOUR_SITE_ID"></script>

The proxy install serves both s.js and the collector from your own domain, so ad blockers — which match on domain, not path — can't see us. You rewrite one innocuous path prefix to our CDN; the script figures out the rest.

An async view forwards the prefix with httpx.

Add the view

analytics/views.py
import httpxfrom django.http import HttpResponseTARGET = "https://cdn.datalook.app"async def datalook_proxy(request, path):    headers = {"X-Forwarded-For": request.META.get("REMOTE_ADDR", "")}    async with httpx.AsyncClient() as client:        if request.method == "POST":            up = await client.post(f"{TARGET}/{path}", content=request.body,                headers={**headers, "Content-Type": request.content_type or "text/plain"})        else:            up = await client.get(f"{TARGET}/{path}", headers=headers)    res = HttpResponse(up.content, status=up.status_code)    res["Content-Type"] = up.headers.get("content-type", "application/octet-stream")    return res

Wire the URL

urls.py
from django.urls import re_pathfrom analytics.views import datalook_proxyurlpatterns += [re_path(r"^_axis/(?P<path>.*)$", datalook_proxy)]

Point the script at the prefix

<script defer src="/_axis/s.js" data-site="YOUR_SITE_ID"></script>

Heads up

Your server now sits between the visitor and us, so forward the visitor IP (X-Forwarded-For) or your country breakdown will collapse to your server location. The DNS proxy avoids this entirely — see the proxy overview.