Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Tracking logged in users in Matomo or Google Analytics

Started by Japhy 7 years ago · 3 replies · 1387 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 Jerry Hunt, 4 days ago
2 99 16 hours ago
General · by pamtbaau, 21 hours ago
1 63 21 hours ago
General · by Andy Miller, 1 day ago
0 48 1 day ago
General · by Marcel, 12 months ago
6 357 5 days ago
General · by Duc , 6 days ago
3 45 6 days ago