From f07a912d67489629af1f2e6415df569e4a6828c6 Mon Sep 17 00:00:00 2001
From: Neophytis <37024002+Neophytis@users.noreply.github.com>
Date: Thu, 10 Sep 2026 22:54:08 +0200
Subject: [PATCH] feat(analytics): parameterize Plausible script URL via
PLAUSIBLE_SCRIPT_URL env var
Empty by default (no tracking in dev). Set to the site-specific script URL
at deploy time for stage and prod independently.
---
.env | 2 ++
config/packages/twig.yaml | 3 +++
templates/base.html.twig | 7 +++++++
3 files changed, 12 insertions(+)
diff --git a/.env b/.env
index fd05b43d6f..bb9fb97e4b 100644
--- a/.env
+++ b/.env
@@ -34,6 +34,8 @@ PaypalBusinessAddress=sb-wbsnh1984149@business.example.com
PaypalUrl=https://www.sandbox.paypal.com/cgi-bin/webscr
PaypalScrPixel=https://www.sandox.paypal.com/en_US/i/scr/pixel.gif
+PLAUSIBLE_SCRIPT_URL=
+
###> symfony/mailer ###
MAILER_DSN=smtp://mailer:25
###< symfony/mailer ###
diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml
index 17bdef7e88..aced5e3673 100644
--- a/config/packages/twig.yaml
+++ b/config/packages/twig.yaml
@@ -7,6 +7,9 @@ twig:
- 'ckeditor/ckeditor.html.twig'
- 'tomselect/tomselect.html.twig'
+ globals:
+ plausible_script_url: '%env(default::PLAUSIBLE_SCRIPT_URL)%'
+
paths:
'%kernel.project_dir%/build': 'build'
'%kernel.project_dir%/public/images': 'images'
diff --git a/templates/base.html.twig b/templates/base.html.twig
index 94d84f97da..d757fefd7c 100644
--- a/templates/base.html.twig
+++ b/templates/base.html.twig
@@ -29,6 +29,13 @@
{% block stylesheets %}{% endblock %}
{% block matomo %}{% endblock %}
+ {% if plausible_script_url %}
+
+
+ {% endif %}