Django Plausible

Django module to provide easy Plausible integration, with Wagtail support

It’s no secret I’m a huge fan of Plausible when it comes to analytics. I’ve jumped around a number of different platforms, and this one just clicked. I’ve been running Plausible on my websites (yes, even this one) for a while now.

Adding it to your website is as simple as just adding a script:

HTML
<script defer data-domain="yourdomain.com" src="https://plausible.io/js/plausible.js"></script>

Solutions like that are often not suitable for environments like CMSs, especially those hosting multiple sites, where certain aspects need to be dynamic and controlled by users who may not have or need access to the code itself.

I’m a full-time developer who works with Django, so I created django-plausible to help with that. It exposes some handy template tags which make adding Plausible very simple, and allow it to react to multiple sites.

Django/Jinja
{% load plausible %}

{% plausible %}

Will result in:

HTML
<script defer data-domain="example.com" src="https://plausible.io/js/plausible.js"></script>

And, allows some further customization:

Django/Jinja
{% plausible plausible_domain="my-plausible.com" script_name="plausible.hash.js" %}

It additionally supports Wagtail (I do work for Torchbox, after all), so it can be configured from the Wagtail admin using Wagtail’s settings.

Share this page