From c68bfec4be04740de24a0108590f03bb3d9d37cf Mon Sep 17 00:00:00 2001 From: K Muller Date: Mon, 13 Jul 2026 14:35:54 +0200 Subject: [PATCH] fix: :bug: fix cookie duplicating matomo script --- resources/ts/front/Components/Layout/Head.tsx | 7 ++++++- resources/ts/front/lib/cookie.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/resources/ts/front/Components/Layout/Head.tsx b/resources/ts/front/Components/Layout/Head.tsx index 26f490b..7c0adba 100644 --- a/resources/ts/front/Components/Layout/Head.tsx +++ b/resources/ts/front/Components/Layout/Head.tsx @@ -28,7 +28,12 @@ export default function Head({ title, description }: HeadProps) { return ( {title} - {description && } + {description && ( + <> + + + + )} {title && } diff --git a/resources/ts/front/lib/cookie.ts b/resources/ts/front/lib/cookie.ts index cace10e..c27570b 100644 --- a/resources/ts/front/lib/cookie.ts +++ b/resources/ts/front/lib/cookie.ts @@ -293,6 +293,14 @@ export const createServiceHandlers = ( ); return; } + // If the script is already in the DOM, Matomo is already running — do not + // re-push into _paq (would trigger "setTrackerUrl/setSiteId registered more + // than once" warnings caused by applyDecidedStatuses being called multiple times). + // Added 13/07/2026 + if (document.getElementById("script-matomo")) { + notifyConsentChange("matomo", accepted); + return; + } const w = window; w._paq = w._paq ?? []; w._paq.push(["trackPageView"]);