Easily track Events within Matomo Analytics thanks to Matomo Tag Manager
In this article we’ll cover what events in Matomo Analytics are; and how you can easily set them up thanks to Matomo Tag Manager.
Key concepts within this article
- Quick definition of the Tag Management System
- Matomo config
- Creating triggers
What are events in Matomo Analytics and why are they useful?
Events allow you to measure interactions on your website which are not defined by default. With them you can measure clicks on some elements of a page, such as, how visitors are interacting with dropdown menus, media players, scrolling behaviours etc. You can also use them to define goals which make them a key feature in Matomo Analytics. Learn more about tracking events in Matomo.
You can easily access the Events report in Matomo Analytics by clicking on the Behaviour category:
And you may read the following message and feel a bit frustrated:
“There is no data for this report” is a nice way to say, “Hey, you are tracking just a tiny part of what Matomo Analytics can do for you.”
Matomo is a great software, but it can’t guess what you want to track.
In order for Matomo to register those event tracking interactions, you’ll need to explain it by adding a line of code similar to this one when the interaction happens:
_paq.push(['trackEvent', 'Here you enter whatever you want', 'Here too', 'and here also']);
Let’s imagine you want to track a click on an HTML button, your code will look something similar to this at the moment of the interaction:
As you can imagine, two main challenges will arise for non developers:
- How to access the source code?
- How to define the interaction?
Luckily, Matomo Tag Manager makes those steps easy for you. Let’s see how the same tracking is implemented with Matomo Tag Manager.
A quick definition of what Matomo Tag Manager is
Matomo Tag Manager lets you manage all your tracking and marketing tags in one easy-to-access place. Please visit this page to learn more about Matomo Tag Manager. In order to start using it, you’ll need to copy/paste a tracking code, named a “container”, within the section of your pages.
Once the container is on your website, all you need to do is to follow these simple steps:
- Add a Matomo Tag.
- Assign the condition to fire the tag (what we call the trigger).
- Publish your work.
- And enjoy
1 – Add a Matomo Event tracking code
All you have to do here is click on “CREATE NEW TAG”
Once selected, just mention how you’d like this tag to be named (it is for your internal purpose here so always use an explicit tag name) and the Matomo configuration (the default configuration setting will be fine in most of the cases):
Then Matomo Tag Manager will ask you the type of tracking you’d like to deploy, in this case, this is an event so select “Event”:
Then all you need is to indicate the values you’d like to push through your event:
To put it in perspective, all we did here through Matomo Tag Manager was implement the equivalent of the following line of code:
_paq.push(['trackEvent', 'Element interactions', 'Click button', 'Click Me']);
Let’s now see how can we do this on click code part which we call a trigger.
2 – Assign the condition to fire the tag
In order to execute the event we’ll need to define when it will happen. You do this by clicking on Create a new trigger now:
As the interaction we’d like to track is happening when a click occurs, it will be a click trigger, and as our button is not a link, we’ll select All Elements Click:
Once selected you’ll need to be precise on the condition in which the event will be triggered. In this case we do not want to have events pushed every time someone is clicking on something on our website. We only want to track when they click on this specific button. That’s the reason why our trigger is set to fire only when the click occurs on an element which has an id and has the value “cta”:
Once you click on the green button named CREATE NEW TRIGGER, you validate the tag by clicking on CREATE NEW TAG:
Then you can move to the last part.
3 – Publish your work
That’s why when you create your tag it doesn’t go live straight away on your website. In order to do this you need to publish your tag and this is what the “Publish” category is designed for:
After that, click on the second button if you’re confident your tag and trigger are both ready to go live:
4 – Enjoy
Well done. As your tag is now live, every click made on this button will now be pushed to your Matomo Analytics account within:
1. The visitor log report:
2. The events report:
You may now be asking, « That’s great, but can I collect something more exciting than clicks? »
Of course you can! This is what the Matomo Tag Manager is all about.
As long as you can express it through a trigger you can really push whatever you want to Matomo Analytics. You can track scrolling patterns, an element visible on the page like an image, an ad or the time spent on the page. The options are now open to you with Tag Manager. And if you need to trigger a tag when certain HTML elements are clicked that match a CSS selector, we got you covered too.
Give them a try! Change the triggers, start playing around with variables and discover that the possibilities are endless.
Tag Manager training videos
Want to get a quick overview on how to use Tag Manager? Here’s a free training series for you to kickstart your tag manager journey.