Choosing your tracking method: Matomo Tag Manager or Matomo JS
You can configure tracking in Matomo using Matomo Tag Manager (MTM) or the Matomo JavaScript (JS) tracker code. It is highly recommended to use only one tracking method, preferably Matomo Tag Manager. While there are rare cases where both tracking methods might be used, this approach is discouraged as MTM can fully meet all your tracking needs on its own. It offers the same benefits as the Matomo JS tracker and more.
Matomo Tag Manager comes with added flexibility, centralised management, and other advanced features for enhanced web analytics. Choosing your tracking method will depend on your Matomo users’ technical familiarity. If technical teams are managing the tracking, they may want to work with the Matomo JS tracker code.
On the other hand, marketing teams might prefer managing tracking through the tag manager’s user interface, which requires less technical expertise. For users unfamiliar with Matomo Tag Manager, the tracker code may seem like a more straightforward option, though MTM offers a comprehensive solution once users become accustomed to it.
Tracking with Matomo Tag Manager
Matomo Tag Manager is a versatile feature for managing and deploying tracking tags without having to modify the website’s code.
- Create custom tags, install third-party tags, and setup triggers and variables in a tag manager container for control over when and how tracking occurs.
- Tag Manager streamlines basic and advanced tracking setups that use multiple tags and custom triggers, and you can update tracking scripts across different pages without accessing the website’s code.
- The default tag manager container is preconfigured with the same tracking coverage as the standard Matomo JS tracker, so you do not need to use both tracking methods.
- Matomo Tag Manager also offers a predefined Matomo Analytics Tag that allows you to setup tracking for common actions like page views, events, and goals without having to write custom code.
- Preview and debug your tag manager setup before publishing to your website.
Implementing Matomo Tag Manager offers an organised and centralised approach that simplifies updates and adjustments.
Tracking with Matomo JS
Matomo JS is a piece of JavaScript code embedded directly into your website’s HTML. This approach is commonly used when applying the same tracking script across all pages without the need for dynamic changes or conditions.
- It collects data on user interactions, such as page views and events.
- You can extend and customise the Matomo JS code to track specific events and configure tracking parameters like user IDs.
- Custom JavaScript functions can interact with the Matomo JS tracker to capture more granular data.
- The Matomo JS tracking method can be configured for detailed tracking on any type of website or app, including eCommerce sites and content and media platforms.
- Implementing the Matomo JS tracker code is straightforward; simply add the tracking code snippet to your site’s HTML.
You can directly manage tracking configurations and updates within the website’s code base, which is useful if you want to customise the tracking to suit your specific needs.
Dual tracking with Matomo JS and Matomo Tag Manager
Important note: It is not recommended to use both the Matomo JS tracker code and Matomo Tag Manager simultaneously. Tracking with both methods can result in conflicts with the timing and sequence of tracking code execution, which might lead to unexpected behaviours, incomplete tracking, and data discrepancies.
However, in the unlikely scenario where both tracking methods are active, it is crucial to keep the following in mind:
- The Matomo Tag Manager container code must be loaded first, so ensure the tag manager container code snippet is placed above the JS tracker code.
- Check the Matomo Variable configuration in tag manager has the following options disabled: Register as default tracker and Bundle Tracker.
- Carefully plan and coordinate which tracking method is responsible for each tracking event. Use one system to handle specific tags and avoid overlapping configurations.
- Utilise Matomo Tag Manager’s debugging tool to test and verify that your tags, triggers, and variable are working correctly.