How to set user ID for Moodle environment?

  1. Is the following script is correct for adding userID in matomo?
    Whether UserID in matomo will automatically generated after this code or I have to add some where else?
1 Like

can any one assist me?


<?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']);" } ?>

I added this after var _paq = window._paq || [];

Still User ID is not working for me. I asked the same from February 2020.