How to update User Id After a first submited User Id?

Hi,

I want update the User Id After some form post in my website, for example:

1 - Unknown User enters in my web site ( trigger matomo to register a new visitor, generated random string userid like as 11111111)
2 - Unknown User Navigates in my website (Generate all data and send to matomo, using id 11111111)
3 - Unknown User Registrate into my newsletter form (name & email) *, (I call setUserId again passing the email, now userId should be user@email.com)
4 - User@email navigate to contact page

*** At this point, I tried to call:
setUserId, “user@email.com”
and
trackPageView

But it generates a new visitor/action in matomo, uncoupled from random id used before (111111).

And in matomo, I have a wrong situation, it shows:

User: 1111111
Navigate between pages

User: user@email
Navigate to contact Page.

Is wrong use the ‘trackPageView’ to UPDATE the currently unknown UserId?

You should not set a fake user ID, just let it empty and Matomo will associate the pages without user ID to the further ones with the good user ID (if you do not change browser IP address, and so on).

Tanks!

But, I’m not generating fake user’s id, the sample above (11111111) was just a reference to “hash” generated by matomo it self.

Also, Am I using the correct flow to update the User Id? Or there is another way to do so?

Again, thank you very much for reply =)

Best Regards
RN

I don’t understand… You wrote:

As I see again, it means that you called setUserId previously.
You shouldn’t call setUserId while you don’t know the user ID…

1 Like

Note: you can also have a look at this interesting FAQ: How are requests with a User ID tracked? FAQ - Analytics Platform - Matomo

1 Like