Cookie value of _pk_id changes for every page view

Hi,

I use the Matomo Analytics tag in the Matomo Tag Manager. I have checked Require cookie consent in the configuration variable. I am storing consent information in a 3rd party tool. Therefore I am using three tags to realize tracking with/without cookie consent, depending on the users’ choice:

  1. Matomo Analytics - Initialize (Prio 0)
  2. Custom HTML - call _paq.push(['setCookieConsentGiven']); or not (Prio 100)
  3. Matomo Analytics - Pageview (Prio 999)

Those three tags are all fired on the same trigger, a simple pageview without any filter.

My understanding is that Initialize will completely set up the tracker, as if I was using the JS tracker and calling _paq.push(['requireCookieConsent']); during setup. Then my custom tag either grants consent or not, while the third tag executes the pageview tracking with the applicable consent setting.

I can see that the cookie _pk_id is being written when consent was given. The problem I see is that the value in the cookie changes with every pageview. Therefore if I open the site, have the cookie set and come back after 30 minutes have passed, those two visite are not being tied together as they should be.

My assumption about intended behavior is that when you give cookie consent the first time, the cookie will be written with a unique id. The calls to setCookieConsentGiven on subsequent pageviews should only decide whether the id from the cookie is sent along in tracking requests or not. They should not rewrite the id itself with a new value each time.

Is what I am seeing intended, that the id in the cookie changes with every pageview? Or am I doing something wrong?

I experience the very same problem with _pk_id value changing per each pageview. Example:

771df5fd60e8cd25.1657202851.
487bf78b6ed2bf0f.1657202880.

Second part is somewhat similar (timestamp?), but I don’t think these values should be different.

@DerBob

  1. were you able to resolve this issue?
  2. do you use Matomo Tag Manager + Matomo Cloud?

Thanks.

I have digged into this and it looks like first part of the _pk_id value is visitor ID which I can see also in backend, second part is some kind of timestamp (I guess).

@ebr in post https://forum.matomo.org/t/two-different-id-visitors-for-the-same-id-visit/26583b describes a similar behaviour, however there is no reply/feedback on that post as usual.