Tracking logged in users in Matomo or Google Analytics

I was using wordpress and a plugin before which took care of the user id’s

Would like to track users in Grav with Matomo as well, anyone tried this?


Did you search the web for “grav plugin matomo”? I got at least three promising results including two plugins.

Sorry about that, forgot to mention that I wanted to use Matomo Tag Manager and I was under the impressions these plugins only work with regular Matomo id

Edit: i had another look at the existing plugins but they don’t seem to track logged in users either

I had to solve it without plugins because none were doing this. So in case I can help anyone with my solution:

Before the MTM tag in your template add:

<script type="text/javascript">
var _mtm = _mtm || [];
_mtm.push({'setUserId': '{{ grav.user.username }}'});

Then go into Matomo tag Manager
Create a new Variable
Pick Data Layer
Enter a name
Enter layer variable name: setUserId

Got to your basis variable Matomo-configuration
Find User ID and click the arrows next to the input field
Select your newly made data layer variable
Save and publish

Done! You really don’t need plugins for that

1 Like