I'm trying to setup Matomo with Joomla's user id or email. But with no success.
I'm using the Matomo's java Tracking code in a Joomla plugin and added the following as instructed by Matomo help:
_paq.push(['setUserId', 'userID']);
I then set a variable in Matomo to get the content of usedID and use it to track users by ID.
I understand that i have to populate userdID with Joomla's user id and i've tried a lot of attempts to do that that with no success. Mainly because i don't know where to put the code. I've inserted in the plugin above the Tracking script ...

So, any ideas please?