Before you start
Create a free Cool Analytics account and add your site. You'll get a site ID — replace YOUR_SITE_ID in the code below with it. The dashboard shows the snippet with your ID already filled in.
Install on Django
- 1Open your base template, e.g. templates/base.html.
- 2Paste the snippet inside <head>. Optionally wrap it in an {% if %} on a setting you pass to templates, so it only renders in production.
- 3Deploy.
{% if not debug %}
<script defer src="https://coolanalytics.dev/hb.js" data-site="YOUR_SITE_ID"></script>
{% endif %}Check that it works
Open your live site in a new tab, then open your Cool Analytics dashboard. Your visit appears on the live map within seconds — with the page you're on, where you came from and your browser.
Nothing showing up? Make sure you're looking at the published site (not a preview or editor), that an ad blocker isn't blocking the script, and that you're not testing on localhost.
Track signups, purchases and clicks
Pageviews, sources, countries and outbound link clicks are tracked automatically. For the moments that matter to you, send a custom event. Events named like a signup show up as signups, and events with an amount show up as revenue — on the live map and per traffic source.
// anywhere in your Django site's browser code
window.hb?.track("signup");
// with an amount, it shows up as revenue
window.hb?.track("purchase", { amount: 49 });Django tips
- The debug template variable is only set when DEBUG = True and your IP is in INTERNAL_IPS (with the debug context processor enabled). Otherwise it's empty — so the snippet renders.
- Works the same with Wagtail: put it in Wagtail's base.html.
Want to keep your own visits out of the stats? Open your site once with #hb-ignore at the end of the URL. That browser is excluded until you visit with #hb-track.
Django analytics FAQ
Does it work with HTMX?+
Pages loaded with hx-boost use the history API, so they're tracked as pageviews.
Can I track a form submit?+
Yes — call hb.track('contact') in the browser when the form succeeds, or render a small script on the thank-you page.
Do I need a pip package?+
No. One template tag is all it takes.