@TPapajCin opened this Issue on February 21st 2018

Hello, there's a problem in Matomo with leaving old "userID-empty" visits when visitor gets own userID when that userID already has a visit.
I'm using newest version of Matomo(3.3.0).

How to reproduce:

  • Use private mode or something to make your browser "clean" so you are counted as a new, fresh visitor.
  • Generate some actions on tracked page. For example generate 5 actions: now there is one visit with 5 actions for visitor without any userID.
  • Next action(for example logging in) should give that visitor some userID not used in any current ongoing visit. Matomo will replace empty userID for that visit with correct one and change visitorID if needed. Our "userID-less" visit with 5 actions now has userID and 6 actions. So far everything is correct.
  • Make your browser clean again so you are counted as a second visit. For example generate 3 actions so there's a new visit with 3 actions.
  • In this point we have two visits: first one with 6 actions and userID, second one with 3 actions and no userID.
  • Next action(logging in) for that second visit should give this visitor the same userID as in previous visit, this needs to happen before visit timeout for that first visit. Matomo will recognize the user and new events will be connected to the previous visit that had userID.
  • Here is where the problem begins: Matomo starts counting all actions again for the first visit with userID but it leaves previous actions from second visit.
  • In this moment we have two visits: first one with 7 actions and userID, second one with 3 actions and no userID.

What should happen instead? That second visit with 3 actions should be connected to that first visit.

Why there's a problem? When last visit for reused userID already ended because of timeout, there's no problem because Matomo just updates record with new visit and writes new userID for the visit. When there's ongoing visit for that userID, Matomo can't just update userID for the new visit because there would be two separate visits for the same userID that hasn't ended yet but current Matomo reaction to this situation also isn't good because it can create false data about users that end their visits on login website.

The best way to fix it from the functional side would be to update idvisit of all old events from piwik_log_link_visit_action with the correct one and delete that second visit from database. This would merge these visits and leave only correct one. I don't know however if this wouldn't create too much load(searching the data with specific idvisit).

@mattab commented on November 2nd 2019 Member

Here is where the problem begins: Matomo starts counting all actions again for the first visit with userID but it leaves previous actions from second visit.
[...] When there's ongoing visit for that userID, Matomo can't just update userID for the new visit because there would be two separate visits for the same userID that hasn't ended yet

Currently it is by design, if the second "visit" happens within 30min of the first one, then the actions/pageviews/etc will be added to the existing visit as per the visit definition in https://matomo.org/faq/general/faq_36/

but current Matomo reaction to this situation also isn't good because it can create false data about users that end their visits on login website.

It would be interesting to know when a logout/login happens though, as it may indicate some issue or bug in the website/app... What I would recommend is that, when users login again, you could force Matomo to create a new visit manually yourself, see: https://matomo.org/faq/how-to/faq_187/

(I reckon we won't change this behavior in Matomo because it would be hard to detect + it would probably end up creating too many visits in some cases when for example on one page you forget to set a User ID and on the next page you set it again. Will mark as closed for now but we could reopen if needed)

This Issue was closed on November 2nd 2019
Powered by GitHub Issue Mirror