Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique visitor ID not working with setCookieConsentGiven and addTracker #19511

Open
dieisraels opened this issue Jul 11, 2022 · 3 comments
Open
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced.

Comments

@dieisraels
Copy link

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
@dieisraels dieisraels added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Jul 11, 2022
@peterhashair
Copy link
Contributor

peterhashair commented Jul 12, 2022

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
Copy link
Member

sgiehl commented Jul 21, 2022

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
Copy link
Member

tsteur commented Jul 21, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced.
Projects
None yet
Development

No branches or pull requests

5 participants