@MichaelHeerklotz opened this Pull Request on October 16th 2018 Contributor

Added a new setting "userId linked to visitorId" (default: enabled), that allows to turn off the default "userId overrides visitorId" behaviour as a per-site setting.

This is useful for example when using the third party cookie, and thus all Matomo sites use the same "global" visitorId for the same device, and some Matomo sites set a userid. In this case, once a site sets a userid, the vistiorId will change and make it impossible to follow a visitor when traveling through different matomo sites.

With this setting, this behavior can be adjusted. userId and visitiorId will no longer influence each other when the new setting is disabled.
However, different devices with the same userId will also no longer share the same visit and visitorId.

@MichaelHeerklotz commented on October 16th 2018 Contributor

Apparently "isUserIdLinkedToVisitorId()" in the Request class will cause a database operation which is undesired when using the QueuedTracking plugin. I guess the setting needs to be made global. I will update my PR tommorrow.

@MichaelHeerklotz commented on October 17th 2018 Contributor

This pr https://github.com/matomo-org/plugin-QueuedTracking/pull/87 will fix the db connection issues in the QueuedTracking plugin. It is safe to replace the call to getVisitorId() with getVisitorIdForThirdPartyCookie() there.

Furthermore, a call to isUserIdLinkedToVisitorId() will not always cause a db connection, because the result of Cache::getCacheWebsiteAttributes() is already cached between requests.

Thus I think this is the best way to do it.

With this fix, all issues caused by this pr in Travis CI seem to be gone, so this pr should be good to pull.

@MichaelHeerklotz commented on October 17th 2018 Contributor

Depending on when this gets pulled, the "core/Updates/3.6.1-b4.php" file needs to be adjusted to the correct version.

@MichaelHeerklotz commented on October 18th 2018 Contributor

In matomo-php-tracker this line https://github.com/matomo-org/matomo-php-tracker/blob/master/PiwikTracker.php#L1243 will return a wrong visitorId if this new setting is deactivated, however since the JS tracker only returns the cookie value https://github.com/matomo-org/matomo/blob/3.x-dev/js/piwik.js#L5693 maybe it would be good anyway, to sync the php tracker with the js tracker and do the same (only return the cookie value)

Powered by GitHub Issue Mirror