I suspect this is an issue in the datapunt/matomo-tracker.js library or how we call the tracker module in the addon:
|
"@datapunt/matomo-tracker-js": "0.5.1", |
Even if the confirm_tracking cookie has not been set, on initial load of the dsgvo add'on, a unique Matomo _pk_id cookie is set. The pageview tracking does not occur, but addblockers like ghostery are already responding on the setCookie (we got a complaint from a visitor on the client project using volto-dsgvo-banner.
I think the problem in here, where the tracker is always initialised and immediately sets the cookie. But I'm a bit wary with my state management/hooks knowledge in React, would it be safe here to move the tracker initialiasation in the useEffect? Or will that mess up the state as the tracker object is also in the useEffect variables array.
|
const Matomo = ({ matomoTracker }) => { |
|
const [cookies] = useCookies(); |
|
const confirmTracking = !!Number(cookies.confirm_tracking); |
|
let tracker; |
|
|
|
if (__CLIENT__) { |
|
tracker = new matomoTracker.default({ |
|
urlBase: config.settings.DSGVOBanner.tracker.urlBase, |
|
siteId: config.settings.DSGVOBanner.tracker.id, |
|
}); |
|
} |
|
|
|
useEffect(() => { |
|
if (confirmTracking) { |
|
tracker.trackPageView(); |
|
} |
|
}, [tracker, confirmTracking]); |
The matomo-tracker-js readme mentions a separate subkey 'configurations' where you can disable setting cookies. But as soon as a visitor does give consent, you'd want to enable it again. Maybe it is enough to add disableCookes as an option to the tracker initialisation as long as consent hasn't been given.
https://www.npmjs.com/package/@datapunt/matomo-tracker-js
I suspect this is an issue in the datapunt/matomo-tracker.js library or how we call the tracker module in the addon:
volto-dsgvo-banner/package.json
Line 81 in d15ce58
Even if the confirm_tracking cookie has not been set, on initial load of the dsgvo add'on, a unique Matomo _pk_id cookie is set. The pageview tracking does not occur, but addblockers like ghostery are already responding on the setCookie (we got a complaint from a visitor on the client project using volto-dsgvo-banner.
I think the problem in here, where the tracker is always initialised and immediately sets the cookie. But I'm a bit wary with my state management/hooks knowledge in React, would it be safe here to move the tracker initialiasation in the useEffect? Or will that mess up the state as the tracker object is also in the useEffect variables array.
volto-dsgvo-banner/src/components/Banner/Matomo.jsx
Lines 6 to 22 in d15ce58
The matomo-tracker-js readme mentions a separate subkey 'configurations' where you can disable setting cookies. But as soon as a visitor does give consent, you'd want to enable it again. Maybe it is enough to add disableCookes as an option to the tracker initialisation as long as consent hasn't been given.
https://www.npmjs.com/package/@datapunt/matomo-tracker-js