fix: 🐛 fix cookie duplicating matomo script

This commit is contained in:
K Muller 2026-07-13 14:35:54 +02:00
parent 81c8686808
commit c68bfec4be
2 changed files with 14 additions and 1 deletions

View file

@ -28,7 +28,12 @@ export default function Head({ title, description }: HeadProps) {
return (
<InertiaHead>
<title>{title}</title>
{description && <meta name="description" content={description} />}
{description && (
<>
<meta name="description" content={description} />
<meta property="og:description" content={description} />
</>
)}
{title && <meta property="og:title" content={title} />}
<link rel="canonical" href={canonical} />
<meta property="og:type" content="website" />

View file

@ -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"]);