Skip to content

Matomo unique ID cookie _pk_id is set, even if no consent has been given yet #35

@fredvd

Description

@fredvd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions