Tracking before login and after

Hi,

I have a webpage with login (username is email).
I want to track what a user done before the login, and after the login,
but when I use SetUserId(with the email) it seems that a new session is created, losing all of the user before-login actions.

Is that something possible with Piwik ?

but when I use SetUserId(with the email) it seems that a new session is created, losing all of the user before-login actions.

When you set the user ID then Piwik should attribute the whole session before login to the same “user id” visit

This was done in 2.9.0 so make sure to use latest piwik version

I am using Piwik 2.10.0 and it still records 2 different visits.
This PR Store visitorID related to userID to cookies by jantlwoomy · Pull Request #6838 · matomo-org/piwik · GitHub fix it.