Quantcast
Channel: Support & Bugs - Matomo forums
Viewing all articles
Browse latest Browse all 5981

Reading userId in Javascript

$
0
0

Hello

After looking at the javascript documentation and multiple searches on forum.matomo.org I found the following 2 ways:

<script>
var currentUpdatedUserId ;
    _paq.push([ function() { currentUpdatedUserId = this.getUserId(); }]);
  currentUpdatedUserId = window.Matomo.getAsyncTrackers()[0].getUserId();
</script>

The 1st one just results in the variable being undefined (so it is not set)
The 2nd one gives an error: Uncaught TypeError: Cannot read properties of undefined (reading ‘getAsyncTrackers’)

Thanks in advance

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5981

Trending Articles