diff --git a/src/utils/matomo.ts b/src/utils/matomo.ts index 0d557c006..0cac683c7 100644 --- a/src/utils/matomo.ts +++ b/src/utils/matomo.ts @@ -1,7 +1,7 @@ export const track = (category: string, action: string, name: string, ignoreReferrer?: boolean) => { if (window && window.please) { const url = - document.location.ancestorOrigins.length > 0 + document.location.ancestorOrigins && document.location.ancestorOrigins.length > 0 ? document.location.ancestorOrigins[0] : document.location?.origin || document.referrer if (!ignoreReferrer && url && !url.startsWith('https://impactco2.fr')) {