Uid variable added but getting no userId in Matomo

function matomo(userId) {
  let userId=localStorage.getItem('userEmail');
  console.log("matomo",userId);
  var _mtm = (window._mtm = window._mtm || []);
  // var _paq = window._paq = window._paq || [];
  _mtm.push(["trackPageView"]);
  _mtm.push(["enableLinkTracking"]);
  _mtm.push(["trackAllContentImpressions"]);
  _mtm.push({
    "mtm.startTime": new Date().getTime(),
    event: "mtm.Start",
    uid: userId,
  });
 
  (function () {
    var d = document,
      g = d.createElement("script"),
      s = d.getElementsByTagName("script")[0];
    g.async = true;
    g.src = "";
    s.parentNode.insertBefore(g, s);
  })();
}

We have used this code for tracking userId of logged in user in Angular Project.We are getting userId in console everytime.But in matomo all userId is not saved.We have created uid variable in container and used it.But after that no userId is detected.What is the issue? Please guide us properly.

Closed in favor of: