Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Tracking logged in users in Matomo or Google Analytics

Started by Japhy 7 years ago · 3 replies · 2083 views
7 years ago

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

7 years ago

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

last edited 06/28/19 by Japhy
7 years ago

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:

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

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

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
last edited 07/02/19 by Japhy

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 23 hours ago
2 40 16 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago