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 (omit https:// and www)

  • 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

  1. Open your base template file, typically:

    • templates/base.html

    • templates/layout.html

    • Or your project's main template that other templates extend

  2. Add the Humblytics script just before </head>:

django

  1. Ensure child templates extend this base:

django

Note: {% if not debug %} prevents tracking in development when DEBUG = True.

Best for: Production/staging environments, cleaner configuration

  1. Add to your settings.py:

python

  1. Add to .env file (for production):

env

  1. Create a context processor to make settings available in templates:

python

  1. Register the context processor in settings.py:

python

  1. 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)

  1. Create templates/includes/analytics.html:

django

  1. Include it in each base template:

django

Note: Replace YOUR_ID_HERE with your actual project ID from Humblytics.

4 · Deploy and verify

  1. Clear Django caches (if using template caching):

bash

  1. Restart your Django server:

bash

  1. If using static files CDN, ensure changes are deployed

  2. Return to Humblytics and click Verify Website

  3. Open your live site in a private/incognito window and refresh once

  4. 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 = True

  • Template 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 check

  • Open Developer Tools (F12) → Network tab and search for hmbl.min.js

  • No 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?