Skip to content

Install Statsdot on Django

Updated October 17, 2026

Add the script to the <head> of your base template, for example templates/base.html:

<head>
  {# ... #}
  {% if not debug %}
    <script defer data-domain="yoursite.com" src="https://statsdot.com/js/script.js"></script>
  {% endif %}
</head>

The debug variable is available in templates when django.template.context_processors.debug is enabled and the request comes from an address in INTERNAL_IPS. If you prefer, pass your own setting through a context processor. Visits from localhost are never sent anyway.

Track events with data-statsdot-event="Signup" on a button, link or form. See Events and goals.