We're putting this into 3.X since it's rather urgent eg re some recent court decisions etc.
User confirmed it works... Will need to add some docs once merged and update some pages. Tested it myself as well and worked. It's basically the same as calling this:
Basically it's supposed to work like this:
once you have consent you call
On the next page view you can either not call
disableCookies anymore or you call both but standard behaviour would be to not call
window._paq.push(['disableCookies']); window._paq.push(['enableCookies']); window._paq.push(['setTrackerUrl', u+'matomo.php']); window._paq.push(['setSiteId', '1']); //...
Enable cookies always takes precedency over disable cookies to make this flow work. This is simply because by default cookies are enabled anyway.
What would cause issues is to do this on every page view manually:
tracker.setSiteId(5); tracker.disableCookies(); tracker.enableCookies();
If someone was to execute above code the cookie would change on every request as it's not correctly set up.
disableCookies needs to be set before
setSiteId as otherwise all existing cookies would be deleted.
Some of the tests are changing because we now always overwrite the visitorId of the current visit when the visitorId changes in the JS tracker. Before visitorId was never updated during any visit. Eg the visitorId changes when: