Skip to main content

Django module to provide easy Plausible integration, with Wagtail support

Project description

django-plausible

CI PyPI PyPI - Python Version PyPI - Status PyPI - License

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 to plausible.io)
  • PLAUSIBLE_SCRIPT_NAME: The name of the script to use (defaults to plausible.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 for data-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 %}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-plausible-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

django_plausible-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file django-plausible-0.1.0.tar.gz.

File metadata

  • Download URL: django-plausible-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.11

File hashes

Hashes for django-plausible-0.1.0.tar.gz
Algorithm Hash digest
SHA256 29d9818c880f5fef5fce757ae4a9a3822dc8699549341f3433802c5dc9d8e739
MD5 3a90e7f7f1669e7b037b9490b288e93b
BLAKE2b-256 d7252262961e28143da80bdc4eec45265d10307fc86adddae4140ac9f55c769e

See more details on using hashes here.

File details

Details for the file django_plausible-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_plausible-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.11

File hashes

Hashes for django_plausible-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40cae8fc448409c8890747ff8718706b347b8b4ac0f9e2b94d39bf4701d39eb9
MD5 b75804e01fbd719604c5257362e25a18
BLAKE2b-256 9046c0d757fc6c29f263ba7d9b13e73884a58d56fbfa875acede8b964bc0c736

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page