Incorrect username in the dashboard

Hello All,

We have added an application url to Matomo and the issue is when a user tried to access the URL it’s getting registered in Matomo but it’s displaying as Direct user instead of the actual username. Can someone help to fix this issue?

Can someone assist me on this?

Hi @sbollam
What is your tracking code?

Hi @Philippe

Please find the tracking code attached.

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://test.matomo.com/matomo";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '504']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

Hi @sbollam
In your code, you don’t track user name:

Then you should put _paq.push(['setUserId', 'USER_ID_HERE']); before the trackPageView command.
See also:
https://developer.matomo.org/guides/tracking-javascript-guide#user-id