Pass matomo user id from the body of javascript

In matomo JS tracking, we need to set userId for the users in the tracking code which is placed in the head section.But in my site, i’ll be getting the user id say login name only in the body. How can set the user id in this case?Thanks in advance