@tsteur opened this Pull Request on June 25th 2020 Member

We're putting this into 3.X since it's rather urgent eg re some recent court decisions etc.

refs https://github.com/matomo-org/matomo/issues/13056

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: _paq.push(['setSiteId', YOUR_IDSITE]);_paq.push(['ping']);

Basically it's supposed to work like this:

window._paq.push(['disableCookies']);

once you have consent you call

window._paq.push(['enableCookies']);

On the next page view you can either not call disableCookies anymore or you call both but standard behaviour would be to not call disableCookies anymore.

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:

  • Cookies are disabled. The backend generates a random visitorId not known to the JS tracker
  • Enable cookies. Now JS generates a random visitorId and we want to update the existing visit to enforce this ID
@tsteur commented on June 25th 2020 Member

build js

@tsteur commented on June 26th 2020 Member

build js

@tsteur commented on June 27th 2020 Member

build js

@tsteur commented on June 30th 2020 Member

build js

@tsteur commented on June 30th 2020 Member

build js

@diosmosis commented on July 3rd 2020 Member

build js

This Pull Request was closed on July 3rd 2020
Powered by GitHub Issue Mirror