@dieisraels opened this Issue on July 11th 2022

Expected Behavior

If I add another tracker, then after each page reload the Unique User ID (_pk_id) value is reset when using setCookieConsentGiven:

var _paq = window._paq = window._paq || [];
_paq.push(['requireCookieConsent']);
_paq.push([ 'setCookieConsentGiven' ]);
_paq.push(['trackPageView']);

(function() {
    var u="URL";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '3']);
    _paq.push(['addTracker', 'ANOTHER_URL', '3']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();

If only one tracker is registered, the Unique User ID remains stored.

Current Behavior

As a result, Matomo no longer tracks users across multiple visits.

Steps to Reproduce (for Bugs)

See live example: https://www.erf.de/test.html

Your Environment

  • Matomo Version: 4.10.1
  • PHP Version: 8.1.7
@peterhashair commented on July 12th 2022 Contributor

ping @sgiehl, this happens when addTracker and setCookieConsentGiven are set, as described the _pk_id will change, but not sure is a bug or expected.

@sgiehl commented on July 21st 2022 Member

I'm unfortunately not very familiar with how this is supposed to work. I can imagine that this might be expected. If each tracker tries to set his own cookie, they might overwrite each other.
Maybe @tsteur is able to say if that is supposed to work. If so the product team needs to decide when we should investigate and fix that.

@tsteur commented on July 21st 2022 Member

Since they are different Matomo's I don't think it's not quite expected that they overwrite each other but there is also maybe no easy fix to it without breaking anything.

A workaround could be to configure one tracker differently using setCookieNamePrefix? so it doesn't use _pk_ as the prefix but a different and thus it won't overwrite the cookie? Potentially this be a use case to document?

I didn't look too deep into it though.

Powered by GitHub Issue Mirror