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?