setUserId not working (empty User IDs report)?

Hi guys. I’ve added some JS code and now my Matomo tracking code (in header) looks like this:

var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['setUserId', userId]);
(function() {
var u="";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src='//'; s.parentNode.insertBefore(g,s);

The variable userId used in _paq.push(['setUserId', userId]); is definitely set when needed.

Now when I go to Matomo > Vistiors > User IDs report, it is empty.

Any ideas why? Do I need to wait for some time?
Do I need to call resetUserId for that to work?



I’m facing the same problem

Does anyone know how to resolve this?

similar issue here, but userId is not empty, but not the value I specified.
When i remove resetuserid from logout/login form page it worked, still i do pass for every logged in page the userid. Does setuserid only works in same call of resetuserid, otherwise matomo will immediately set its own user id which cannot be overwritten?

Does it make a difference, when moving setUserId
inside of (function() {

Same problem here. Does anyone have any news on this issue?