Django
Add Humblytics to your Django site in about 5 minutes.
1. Copy your tracking code
In Humblytics, open Site settings → Install and click Copy tracking code.
2. Add it to your base template
Paste the snippet just before </head> in the template every page extends, usually templates/base.html. Pages that use {% extends "base.html" %} get it automatically.
Only want it in production? Wrap the snippet in a check, for example:
{% if not debug %}
<!-- paste your Humblytics snippet here -->
{% endif %}The debug variable needs django.template.context_processors.debug in your settings and your server IP in INTERNAL_IPS. Or pass your own flag through a context processor.

3. Deploy and verify
Deploy to production.
Back in Humblytics, click Verify install.
Open your live site in a private window and click around. Your visit appears in Observe → Analytics → Overview under Live Activity within about a minute.
Not verifying?
Every page extends the template with the snippet. Pages with their own
<head>need it too.Using
django-csp? Allowhttps://app.humblytics.cominscript-srcandconnect-src, and allow the inline script (with a nonce).
Still stuck? See Verify & Troubleshoot Tracking.
Last updated