Mastering data analytics with Matomo Tag Manager and custom events tracking!

Matomo Tag Manager is a powerful tool that enables efficient event tracking and empowers web analyst to gather valuable insights. Let’s talk about the intricacies of Matomo Tag Manager, explore event tracking capabilities, shed light on the data layer called _mtm for custom events, and discuss the enhanced data analytics and potential applications.

Understanding Matomo Tag Manager:

Matomo Tag Manager is a versatile solution that simplifies the management of tags, triggers, and variables on a website. It acts as a centralised platform to deploy and manage various tracking codes, eliminating the need for manual implementation.

Despite its advantages, it’s worth noting that the debug mode of Matomo Tag Manager can sometimes be challenging. It often requires clearing the cache, and it can be difficult to identify which event triggered a specific tag. However, the benefits of using Matomo Tag Manager for event tracking outweigh these limitations.

The potential of event tracking

Event tracking allows to monitor specific user interactions on a website. Matomo Tag Manager provides a seamless way to track events without modifying the website’s code directly. By setting up event tags and triggers within Matomo Tag Manager, you can capture valuable data points such as button clicks, form submissions, downloads, video plays, and more. These insights provide a comprehensive understanding of user engagement and help optimise website performance.

The Data Layer: using _mtm for custom events

Matomo Tag Manager employs a data layer called _mtm to facilitate the tracking of custom events. The data layer acts as a bridge between the website and Matomo Tag Manager, allowing for dynamic data capture.

Custom events can be defined and triggered based on specific user interactions or actions.

For example, let’s say you want to collect form entries. You can create a custom event using _mtm that triggers when a user submits a form. The _mtm data layer can store relevant information such as form field values, timestamps, and user identifiers. This creative implementation of _mtm allows for personalised and granular event tracking scenarios tailored to specific needs.

Example of _mtm Data Layer Code for collecting form entries

Let’s imagine a scenario where you have a search form on your website, and you want to track a search event using Matomo Tag Manager. To achieve this, you can use the _mtm data layer to capture relevant form entry information. Here’s an example of how the _mtm data layer code might look like:

  window._mtm = window._mtm || [];
    'event': 'search',
    'searchQuery': '[search_query_value]',
    'searchFilters': {
      'category': '[category_value]',
      'location': '[location_value]',
      'priceRange': '[price_range_value]'

  <label for="searchQuery">Search Query:</label>
  <input type="text" id="searchQuery" name="searchQuery">

  <label for="category">Category:</label>
  <select id="category" name="category">
    <option value="electronics">Electronics</option>
    <option value="clothing">Clothing</option>
    <option value="books">Books</option>

  <label for="location">Location:</label>
  <input type="text" id="location" name="location">

  <label for="priceRange">Price Range:</label>
  <input type="text" id="priceRange" name="priceRange">

  <button type="submit">Search</button>

In this example, the _mtm data layer is used to track a search event. The form includes fields for a search query, category, location, and price range. When the user submits the form, the JavaScript code captures the values from these fields and pushes them to the _mtm data layer as part of the ‘search’ event. The values ‘[search_query_value]’, ‘[category_value]’, ‘[location_value]’, and ‘[price_range_value]’ should be replaced with the actual form field values using JavaScript or any server-side scripting language.

Before starting the tag configuration, make sure that the collected search values are stored in custom dimensions and metrics in Matomo. Similar to Google Analytics, Matomo provides a way to set up custom dimensions and metrics.

Configuration in Matomo Tag Manager:

  1. To access the search values as variables in Matomo Tag Manager for our example, follow these steps:
    • Log in to your Matomo Tag Manager account and navigate to the container where you want to create the variable.
    • Create a new variable and select the “Data Layer” type.
    • Configure the Data Layer Variable Name for the variable to match the specific value you want to access. For example, if you want to access the search query, set the Data Layer Variable Name as “searchQuery”.
    • Save the variable.
    • In your Matomo configuration tag, find the section related to custom dimensions and metrics.
    • Assign the previously created Data Layer variable (e.g., “searchQuery”) to the appropriate custom dimensions and metrics to capture the search values. Use the indexes from the Matomo administration panel.
    • Save and publish the tag configuration.
  2. Now you need to create a trigger in Matomo Tag Manager that listens to your custom search event:
    • Create a new trigger and select the “Custom Event” type.
    • Configure the Event Name for the trigger to match the value set for your search event, which is “search”.
    • Save the trigger.
  3. You can now create the tag and associate the search values with the search event in Matomo Tag Manager. Here’s how:
    • Create a new tag or edit an existing one that you want to associate with the search event.
    • Configure the necessary fields and settings for the tag, such as the tracking method, tag type, and firing rules.
    • In the tag configuration, find the section related to triggers or firing rules.
    • Add the custom event trigger we created earlier to the list of triggers for the tag. This ensures that the tag will be fired when the custom event is triggered.
    • Save and publish the tag configuration.

With this setup, whenever the search event is triggered on your website, Matomo Tag Manager will capture the relevant search values and store them in the assigned custom dimensions and metrics within your Matomo environment. You can then use Matomo’s reporting and analysis features to gain insights from this data.

Consult Matomo’s documentation or seek further guidance for specific instructions based on your Matomo version and setup to ensure accurate configuration.

Enhancing Data Analytics with Matomo Tag Manager:

The integration of Matomo Tag Manager with event tracking and custom events significantly enhances data analytics capabilities.

By accurately tracking user interactions, you can gain insights into the effectiveness of marketing campaigns, website design, and overall user experience.

Matomo Tag Manager provides a comprehensive overview of event metrics, including event counts, unique events, event values, and event conversion rates. This wealth of data enables you to identify trends, spot bottlenecks, and make data-driven optimisations to improve business outcomes.

Potential applications and benefits

Matomo Tag Manager’s event tracking and custom events offer numerous potential applications across various industries.

E-commerce businesses can track add-to-cart events, purchase completions, and cart abandonments to optimise conversion rates and sales funnels.

Content publishers can monitor video plays, article reads, and social media shares to refine their content strategies.

SaaS companies can track user onboarding, feature usage, and churn indicators to enhance user engagement and reduce customer attrition. The flexibility of Matomo Tag Manager allows businesses to adapt its event tracking capabilities to suit their specific business objectives.

Matomo Tag Manager stands as a powerful tool for event tracking and custom events. Despite the potential challenges in the debug mode, its benefits outweigh these limitations, enabling businesses to gather valuable insights into user behaviour, optimise website performance, and drive data-informed decisions. By seamlessly integrating event tracking and custom events through the _mtm data layer, you can unlock the full potential of Matomo Tag Manager.

Leave a Reply