Beginner question about data layer in matomo tag manager

Hello,

I’m trying to understand and implement a simply first data layer for tracking as described at https://matomo.org/docs/tag-manager/#data-layer.

So I insert the following code before my container:

<script>
    var  _mtm =  _mtm || [];
    _mtm.push({'weather': 'sunny'});
</script>

I also created a new data layer variable named weather in the container.

But where do I see the values of this variable? Where comes the screenshot in tag manager how to with the text “And then analyze it within Matomo Analytics as shown in the screenshot example below” from? Which step is missing in my case?

Thanks for some help with this!

Best regards,

Timo

And I have a next, more detailled question about this topic:

I defined some other variables:

mtm.push({‘userLogin’: true});
_mtm.push({‘userType’: ‘js’});
_mtm.push({‘userId’: ‘123456’});

Now I what to use these values in a html tag script like this:

<script>
_paq.push(['setUserId', '{{userId}}']);
_paq.push(['setCustomDimension', 1, '{{userLogin}}']);
_paq.push(['setCustomDimension', 2, '{{userType}}']);
</script>

But it seems that this is not working. I don’t see these dimensions in the visitor log.

Do I misunderstand anything or do you see my mistake?

Thanks for some help!

Best regards,

Timo

Hi, did you already check the trainings video’s about the tag manager on https://matomo.org/tag-manager-training/

Perhaps they help with understanding the datalayer

Regards,
Peter

And another addition:

Now I see the dimensions in the visitor log, but the value I see there is something like

login: window.MatomoTagManager.customHtmlDataStore[1]
user_type: window.MatomoTagManager.customHtmlDataStore[2]

How can I get the “real” value and not the object key?

I found a solution for the problem:

<script>
_paq.push(['trackContentImpression', 'Backend', {{PageUrl}}]);
</script>

The variables shout not be passed in single quotation marks in the tag-script.