matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.9k stars 2.65k forks source link

Disparity on how Intranet and Web sites deal with UserId #17002

Open alexandrejobin opened 3 years ago

alexandrejobin commented 3 years ago

I tried to play with the UserId feature on Matomo 4.1.0 and I discovered that the statistics are differents if you track a Website vs an Intranet website.

Stats when tracking an Intranet

  1. Navigate to the home page with Edge browser
    • 1 visit with 1 action with unknown user
  2. Navigate to the login screen
    • 1 visit with 2 actions with unknow user
  3. Login and call setUserId function
    • 1 visit with 2 actions with unknown user
    • 1 visit with 1 action with known user (it didn't merged the pass actions)
  4. Logout and call resetUserId function
    • 1 visit with 3 actions with unknow user
    • 1 visit with 1 action with known user

Stats when tracking a Website

  1. Navigate to the home page with Edge browser
    • 1 visit with 1 action with unknown user
  2. Navigate to the login screen
    • 1 visit with 2 actions with unknow user
  3. Login and call setUserId function
    • 1 visit with 3 actions with known user (it merged the pass actions)
  4. Logout and call resetUserId function
    • 1 visit with 4 actions with know user (it continued to put actions in the same visit)

So at the end, when you track an Intranet site, it doesn't merge pass actions and for a Website, it merge it. Is it normal?

For information:

tsteur commented 3 years ago

Hi @alexandrejobin when you use an "intranet" site then "we trust cookies" and as a result this could be indeed a side effect. I'm assuming this is because usually we would identify the previous visit because of the configId. But now because the visitorId changes when you use the userId feature and we only look for the visitorId it would create a new visit.

I didn't actually try to reproduce this but looking at code this seems to be what is happening.

There is a config setting to change this userId behaviour and you could try changing this in config/config.ini.php if you wanted both to behave the same. Add this to the config:

[Tracker]
enable_userid_overwrites_visitorid = 0

If [Tracker] exists in the config then you would only add the other line to the Tracker section. This would change it for all websites and intranets though and it basically means if the same user use different devices then they won't be shown as the same "visitor" in Matomo.

We might need to adjust https://matomo.org/faq/how-to/faq_19/ and potentially also the userId guide.

@mattab I suppose this is some expected behavior when using userId feature with an intranet website? At least I wouldn't know a way to change this except for on demand for an intranet site setting enable_userid_overwrites_visitorid = 0 but then you don't get information for the same user when they use different devices so that's likely not a good idea.

alexandrejobin commented 3 years ago

I will try to add enable_userid_overwrites_visitorid = 0 to my config because I have a mix of extranet and intranet and I would prefer that all sites get the same logic. But my preference would be that one an anonymous user log to the application that we can merge all his pass actions because this is in fact his actions and we can get a better view of what this user is doing.

Thank you for your quick response!

alexandrejobin commented 3 years ago

I've just tested the enable_userid_overwrites_visitorid = 0 and it have no effect. When I test a Website, it have the same behavior as described in the first post.

tsteur commented 3 years ago

Hi @alexandrejobin just double checking that enable_userid_overwrites_visitorid =0 is part of the [Tracker] section? Does it have an effect on the intranet measurable?

alexandrejobin commented 3 years ago

hi @tsteur

If enable_userid_overwrites_visitorid = 0 is part of the [Tracker] section, both website and intranet react the same:

  1. Navigate to the home page with Edge browser
    • 1 visit with 1 action with unknown user
  2. Navigate to the login screen
    • 1 visit with 2 actions with unknow user
  3. Login and call setUserId function
    • 1 visit with 3 actions with known user (it merged the pass actions)
  4. Logout and call resetUserId function
    • 1 visit with 4 actions with know user (it continued to put actions in the same visit)

Maybe I don't understand correctly but this is like if the enable_userid_overwrites_visitorid = 0 is doing, in fact, what enable_userid_overwrites_visitorid = 1 should do.

tsteur commented 3 years ago

only needs documenting