django-plausible
Django module to provide easy Plausible integration, with Wagtail support.
Installation
pip install django-plausible
Then simply add plausible to INSTALLED_APPS.
Usage
django-plausible provides a plausible template tag, which can be used to output the required script tag for Plausible.
{% load plausible %}
{% plausible %}
Will result in:
<script defer data-domain="example.com" src="https://plausible.io/js/plausible.js"></script>
Configuration
Configuration can be changed either in settings.py, or when calling the plausible template tag:
PLAUSIBLE_DOMAIN: The domain Plausible is running on (defaults toplausible.io)PLAUSIBLE_SCRIPT_NAME: The name of the script to use (defaults toplausible.js). See script extensions for available options.
These settings will affect all calls to the plausible template tag. To override it at call time, you can also pass them into the template tag:
{% plausible plausible_domain="my-plausible.com" script_name="plausible.hash.js" %}
By default, the domain (data-domain) used will be based on the request's hostname (using request.get_host()). To override this, pass site_domain to the template tag.
If the "compat" script is used, django-plausible will automatically add the required id to the script tag. It is excluded by default to help hide Plausible's presence.
Usage with Wagtail
Additionally, django-plausible provides an (optional) deep integration with Wagtail, allowing configuration through the Wagtail admin. To enable this, additionally add plausible.contrib.wagtail to INSTALLED_APPS.
Configuration is done through the "Plausible Analytics" setting:
site_domain: the value fordata-domain. If left blank (the default), the request's hostname will be used (as above), not the site hostname.plausible_domain: The domain Plausible is running on (as above)script_name: The name of the script to use (as above)
To access the template tag, load plausible_wagtail, rather than plausible. The template tag itself is still plausible. Note that unlike the Django variant, the Wagtail template tag doesn't allow options to be passed.
{% load plausible_wagtail %}
{% plausible %}
Release files for django-plausible 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-plausible-0.5.0.tar.gz | 6.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_plausible-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / django-plausible-0.5.0.tar.gz
| Download URL | django-plausible-0.5.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6fbeb1200a86f63cbe83f07e665202a29edeb6b46eb78b393372fb37b945330
|
|
BLAKE2b-256 checksum How to use checksums |
f0496369ba0ba1c4f767f064ed03ae48a7ac795d45f5a61ce1efb6aad623b872
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / django_plausible-0.5.0-py3-none-any.whl
| Download URL | django_plausible-0.5.0-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d132371bafcf2b65afead0ac2eb65cf52d2e6260b22c2999c3a58d1fe60ca9b1
|
|
BLAKE2b-256 checksum How to use checksums |
b1d85ff0ece31b4c97971592e7f4d43803e63eb326b5f6235827daacb534193a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|