DataLook Docs
Install guides

Flask

Install DataLook on Flask — 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.

A blueprint forwards the prefix with requests.

Add the blueprint

datalook_proxy.py
import requestsfrom flask import Blueprint, request, ResponseTARGET = "https://cdn.datalook.app"bp = Blueprint("datalook", __name__)@bp.route("/_axis/<path:path>", methods=["GET", "POST"])def proxy(path):    headers = {"X-Forwarded-For": request.remote_addr or ""}    if request.method == "POST":        up = requests.post(f"{TARGET}/{path}", data=request.get_data(),            headers={**headers, "Content-Type": request.content_type or "text/plain"})    else:        up = requests.get(f"{TARGET}/{path}", headers=headers)    return Response(up.content, status=up.status_code,                    content_type=up.headers.get("Content-Type", "application/octet-stream"))

Register it

app.register_blueprint(bp)

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.