When somebody visits your website, and you associate a User ID with their request, the User ID is associated with their current visit based on a defined set of rules, depending on your specific configuration. You can find details on how this works for common scenarios below.
Note: For clarification on any of the terms used in this FAQ please visit our glossary of analytics terms.
When a User Logs In During a Visit
When a visitor connects to your website but is not initially logged in, their visit is associated with a Visitor ID by default. This is a unique identifier for that specific visit that is not attributed to a specific user. However, once that user logs into their account and you set a User ID for this visitor, then all actions such as page views are linked to the User ID and not the visitor ID. Any previously tracked action for this visitor before the user was logged in is also associated with this User ID.
When a user logs in, Matomo counts all actions before and after logging in as one user, one visit, and one unique visitor.
When a User Logs Out During a Visit
If a visitor is logged in with a User ID set, their visit is associated with their User ID. If the user were to log out, by default, the User ID is remembered for the entirety of the visit.
When a user logs out, Matomo counts all the actions before and after logging out as one user, one visit, and one unique visitor.
It is possible to change this so that any actions taken after the user logs out are associated with a new Visitor ID. Doing so can help to preserve user privacy upon logout but may lead to inflated visit numbers. You can find instructions within the developer documentation on how to reset the User ID when a user logs out.
When a User is Logged In on Multiple Devices
In our multi-device world, it is not uncommon for a single user to be logged in and accessing your site from two devices simultaneously, e.g. a laptop and a mobile device. It is standard practice in Matomo version 4 and above to treat all concurrent visits with a shared User ID as a single visit.
When a user is logged in with two devices sharing a User ID, by default, Matomo counts one user, one visit, and one unique visitor.
How to Treat Different Devices as Different Visits
In some cases, you may prefer to treat each device as a unique visit even if they share a User ID. Especially if you offer substantially different experiences for different device types. If you are using Matomo On-Premise, then you can disable the User ID Overwrites Visitor ID feature by placing the following snippet of code in your
enable_userid_overwrites_visitorid = 0
This will treat each device as a separate visit even if they share the same logged in User ID.
Note: You can also configure this setting on a per site basis.
Where two devices share a User ID and the above setting is disabled, Matomo counts the two devices as one user, two visits, and two unique visitors.
Note: This was the default way of tracking for a short while in Matomo versions 3.13.0 to 3.14.1. Before Matomo version 3.13.0, these visits would have been merged with a single Visitor ID. This was changed to allow both devices and differing visit information to be seen separately.