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

Added site setting: "userId linked to visitorId" #13620

Conversation

MichaelRoosz
Copy link
Contributor

@MichaelRoosz MichaelRoosz commented Oct 16, 2018

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.

@MichaelRoosz MichaelRoosz force-pushed the add_link_userid_to_visitorid_site_setting branch 4 times, most recently from 16834bd to 661f830 Compare October 16, 2018 17:37
@MichaelRoosz
Copy link
Contributor Author

MichaelRoosz commented Oct 16, 2018

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.

@MichaelRoosz
Copy link
Contributor Author

This pr matomo-org/plugin-QueuedTracking#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.

@MichaelRoosz
Copy link
Contributor Author

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

@MichaelRoosz MichaelRoosz force-pushed the add_link_userid_to_visitorid_site_setting branch from 661f830 to baa596d Compare October 18, 2018 15:08
@MichaelRoosz
Copy link
Contributor Author

MichaelRoosz commented Oct 18, 2018

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)

@mattab
Copy link
Member

mattab commented Apr 22, 2019

Thanks for the PR 👍
Closing in favor of #14360

@mattab mattab closed this Apr 22, 2019
@MichaelRoosz MichaelRoosz deleted the add_link_userid_to_visitorid_site_setting branch October 29, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants