Django
Add Humblytics Analytics to a Django Site
1 · Sign up (or log in)
Visit humblytics.com → Start Free Trial. Finish signup—or log in to your existing workspace.
2 · Add your website in Humblytics
In the sidebar, click Add Website.
Domain – enter
your-domain.com(omithttps://andwww)Site Name – internal label (e.g.
Marketing-Django)
Copy the snippet from Install Tracking Code:
html
<!-- Start Humblytics Tracking Code -->
<script async src="https://app.humblytics.com/hmbl.min.js?id=YOUR_ID_HERE"></script>
<!-- End Humblytics Tracking Code -->Keep this tab open—we'll return and click Verify Website once the tag is live.
3 · Add the script to your Django project
Option 1: Direct template integration (simple)
Best for: Quick setup, single environment
Open your base template file, typically:
templates/base.htmltemplates/layout.htmlOr your project's main template that other templates extend
Add the Humblytics script just before
</head>:
django
Ensure child templates extend this base:
django
Note: {% if not debug %} prevents tracking in development when DEBUG = True.
Option 2: Using Django settings (recommended)
Best for: Production/staging environments, cleaner configuration
Add to your
settings.py:
python
Add to
.envfile (for production):
env
Create a context processor to make settings available in templates:
python
Register the context processor in
settings.py:
python
Update your base template:
django
Option 3: Template include (for multiple base templates)
Best for: Projects with multiple base templates (e.g., public site, admin, blog)
Create
templates/includes/analytics.html:
django
Include it in each base template:
django
Note: Replace YOUR_ID_HERE with your actual project ID from Humblytics.
4 · Deploy and verify
Clear Django caches (if using template caching):
bash
Restart your Django server:
bash
If using static files CDN, ensure changes are deployed
Return to Humblytics and click Verify Website
Open your live site in a private/incognito window and refresh once
Within ~30 seconds you should see a green Verified badge and live visitor count
If verification fails, check:
Django-specific issues:
You're testing production environment, not development with
DEBUG = TrueTemplate changes are deployed (check file timestamps on server)
If using template caching, cache is cleared
Context processor is registered (for Option 2)
Environment variable is set correctly in production
Django server was restarted after changes
General issues:
Script ID matches your project in Humblytics
View page source (right-click → View Page Source) and search for "humblytics"
Check Django logs for template errors:
python manage.py checkOpen Developer Tools (F12) → Network tab and search for
hmbl.min.jsNo ad-blockers or browser extensions are blocking the script
Debug in Django shell:
python
5 · Explore & optimize
Dashboard – see traffic, top pages, and referrers
Heatmaps – auto-generated to reveal click hotspots and scroll depth
Experiments – run A/B tests without extra setup (Experiments → New Test)
Last updated
Was this helpful?