User IDs - records

I added the following line in my tracking code:

<?php
// If user is logged-in then call 'setUserId'
// $userId variable must be set by the server when the user has successfully authenticated to your app.
if (isset($userId)) {
     echo sprintf("_paq.push(['setUserId', 'username']);", $userId);
}
?>

But UserID shows no data available. How to proceed with this to get userid data?

Hi,

Just to ask the obvious: You did set the $userId variable to something that is uniquely to this user?
Did you check the source of the website if you can see the _paq.push with the correct username?

image

Without adding the above script my source of the website shows above userid as “13”. If I log in with another id and password it shows the another user id. But all these are not reflected in my matomo dashboard. Can please suggest solution?