Problem with changed idvisitor and idvisit after login

Hi all,
We have a strange problem with matomo log: idvisitor and idvisit of a viewer both change after he/she logs in. My understanding is that after logging in, the viewer’s idvisitor and idvisit should remain the same.
I tested the situation with my own account. When I checked the idvisitor value in Chrome DevTool, everything looked fine. However, in the matomo log collected, both idvisitor and idvisit values changed after log in.
Is there any suggestion for fixing this issue?

Hi @fangyi
Do you use userId while tracking?

Hi Philippe @heurteph-ei
Yes, we are using userId.
I can see my account information in the user_id column of matomo log, but the idvisitor value of the entry is different from the idvisitor before login (i.e. also different from the value I saw in Chrome DevTool when testing). This makes us unable to track a viewer’s journey before login.
During login process, the viewer will be briefly directed to another domain to key in login information, and then directed back to the same page. Could this be the cause of changed idvisit and idvisitor in matomo log?

Hi @fangyi
Is it related to:


Hi @heurteph-ei
Thank you for sharing this information. This is the same situation as what we are experiencing.
At first we tried the solution to set enable_userid_overwrites_visitorid = 1. The new setting indeed made idvisitor maintain the same value before and after a user log-in. However, we observed some bizarre behavior, such as incorrect user_id collected after the user logs in. So we went back to the previous =0 setting.
Currently we are trying out the other solution mentioned in the thread: merging visits within a short timeframe that had matching device and screen specs.