feat(analytics): support new plausible script (#587)
Some checks failed
Build Site / Check and Build for Pull Requests (push) Has been cancelled
Build Site / Build and Deploy on Main Push (push) Has been cancelled

Co-authored-by: welpo <welpo@users.noreply.github.com>
This commit is contained in:
Christian F. Coors 2026-02-03 17:31:00 +01:00 committed by GitHub
parent d73e64032b
commit e04ed249d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 34 additions and 9 deletions

View file

@ -28,11 +28,17 @@
{% if config.extra.analytics.do_not_track %}data-do-not-track="true"{% endif %}>
</script>
{% elif analytics_service == "plausible" %}
{% elif analytics_service == "plausible" %}
{% if analytics_id is matching("^pa-[^\.]+$") %}
{# Use new script available in Plausible 3.1.0 or later #}
<script defer src="{{ get_url(path='js/initializePlausible.min.js', trailing_slash=false) | safe }}"></script>
<script defer src="{% if self_hosted_url %}{{ self_hosted_url ~ '/js/' }}{% else %}https://plausible.io/js/{% endif %}{{ analytics_id }}.js"></script>
{% else %}
<script
defer
data-domain="{{ analytics_id }}"
src="{% if self_hosted_url %}{{ self_hosted_url ~ '/js/plausible.js' }}{% else %}https://plausible.io/js/script.js{% endif %}"
></script>
{% endif %}
{% endif %}