Matomo Tag Manager

By admin , 22 July, 2026
matomo

Matomo Tag Manager acts as a middle layer between your website and tracking tools.

Instead of adding many scripts directly into your website:

Website code
   |
   โ”œโ”€โ”€ Google Analytics script
   โ”œโ”€โ”€ Facebook Pixel
   โ”œโ”€โ”€ Heatmap script
   โ”œโ”€โ”€ Conversion tracking
   โ””โ”€โ”€ Custom JavaScript

you add a single Tag Manager container:

Website
   |
   โ†“
Matomo Tag Manager container
   |
   โ”œโ”€โ”€ Matomo Analytics tracking
   โ”œโ”€โ”€ Events
   โ”œโ”€โ”€ Goals
   โ”œโ”€โ”€ Custom HTML tags
   โ”œโ”€โ”€ Marketing tags
   โ””โ”€โ”€ Third-party integrations

The tags can then be managed from the Matomo interface.


Main concepts in Matomo Tag Manager

1. Containers

A container is a collection of tags, triggers, and variables for a website or application.

Example:

Container: example.com

Tags:
 - Matomo Pageview Tracker
 - Download Tracking
 - Contact Form Event
 - Video Tracking

Triggers:
 - All Pages
 - Button Click
 - Form Submission

Variables:
 - Page URL
 - User ID
 - Product ID

The container generates a JavaScript snippet that is installed on your website.


2. Tags

A tag is a piece of code that performs an action.

Examples:

Matomo tracking tag

Tracks page views:

_paq.push(['trackPageView']);

Event tracking tag

Tracks a button click:

_paq.push([
  'trackEvent',
  'Downloads',
  'PDF',
  'Annual Report'
]);

Custom HTML tag

Runs custom JavaScript, for example:

<script>
console.log("Visitor interaction recorded");
</script>

3. Triggers

Triggers define when a tag should run.

Examples:

Page view trigger

Run on every page:

Trigger:
All Pages

Button click trigger

Run when a visitor clicks:

Trigger:
Click โ†’ Download button

Form submission trigger

Run when:

Form ID = contact-form

4. Variables

Variables store information used by tags and triggers.

Examples:

Page URL
Page Title
User ID
Cookie value
Click text
CSS selector

Example:

A variable could capture:

Button text:
"Download PDF"

and send:

Event Category:
Downloads

Event Action:
Button Click

Event Name:
Download PDF

Benefits of Matomo Tag Manager

1. Less developer dependency

Marketing and analytics teams can add tracking without requesting code changes.

Example:

Before:

Marketing request
        โ†“
Developer ticket
        โ†“
Code change
        โ†“
Deployment
        โ†“
Tracking works

With Tag Manager:

Create tag
     โ†“
Test
     โ†“
Publish
     โ†“
Tracking works

2. Better control over privacy

Unlike many third-party tag managers, Matomo Tag Manager can run entirely within your own infrastructure.

Advantages:

  • Data stays under your control.
  • No mandatory dependency on external advertising platforms.
  • Easier GDPR/privacy compliance management.
  • Works well with self-hosted Matomo.

3. Easier event tracking

Common events can be configured without editing templates:

  • Downloads
  • Video plays
  • Outbound links
  • Button clicks
  • Form submissions
  • Scroll depth
  • Ecommerce interactions

4. Version control and testing

Matomo Tag Manager provides:

  • Preview mode
  • Debug mode
  • Published versions
  • Rollback capability

Example workflow:

Create tag
    โ†“
Preview
    โ†“
Test on staging
    โ†“
Publish version 12
    โ†“
Rollback if needed

Matomo Tag Manager with Drupal

For Drupal websites, the usual setup is:

Drupal
 |
 | Matomo module
 |
 | Loads Tag Manager container
 |
 โ†“
Matomo Tag Manager
 |
 โ”œโ”€โ”€ Page tracking
 โ”œโ”€โ”€ Event tracking
 โ”œโ”€โ”€ Forms
 โ”œโ”€โ”€ Downloads
 โ””โ”€โ”€ Custom analytics

In Drupal's Matomo module:

  • Configure your Matomo URL.
  • Configure your Site ID.
  • Enable the Tag Manager container.
  • Enable "Disable tracking" in Advanced settings.

The reason for enabling Disable tracking is to prevent Drupal from loading the normal Matomo tracking code while allowing the Tag Manager container to control tracking.


When should you use Matomo Tag Manager?

Use it when you need:

โœ… Multiple tracking events
โœ… Marketing campaign measurement
โœ… Custom user interactions
โœ… Ecommerce tracking
โœ… Less dependence on developers
โœ… A privacy-focused analytics workflow

You probably do not need it if:

  • You only need simple page views.
  • You only want visitor counts.
  • You have a small site with no custom tracking requirements.

Recommended Drupal + Matomo architecture

For a professional Drupal site, a clean setup is:

Drupal
 |
 โ”œโ”€โ”€ Matomo Module
 |       |
 |       โ””โ”€โ”€ Loads Matomo Tag Manager container
 |
 โ””โ”€โ”€ Content + user interactions

Matomo Tag Manager
 |
 โ”œโ”€โ”€ Page views
 โ”œโ”€โ”€ Events
 โ”œโ”€โ”€ Downloads
 โ”œโ”€โ”€ Forms
 โ””โ”€โ”€ Custom analytics

Matomo Server
 |
 โ””โ”€โ”€ Database

This keeps Drupal responsible for content management and Matomo Tag Manager responsible for analytics logic.

In the Drupal Matomo module, the option:

Disable tracking
If checked, the tracking code is disabled generally. This may be useful when using Matomo Tag Manager.

means that the Drupal module will stop injecting the normal Matomo JavaScript tracking snippet into your site's pages.

What happens when it is enabled?

Normally, the Drupal Matomo module adds something like this to every page:

<script>
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);

(function() {
  var u="https://your-matomo.example.com/";
  _paq.push(['setTrackerUrl', u+'matomo.php']);
  _paq.push(['setSiteId', '1']);
  var d=document, g=d.createElement('script'),
      s=d.getElementsByTagName('script')[0];
  g.async=true;
  g.src=u+'matomo.js';
  s.parentNode.insertBefore(g,s);
})();
</script>

With Disable tracking enabled, that code is not added.

When should you enable it?

Enable it if:

โœ… You are using Matomo Tag Manager to deploy your tracking tags.

The flow becomes:

Drupal
  |
  | (does NOT inject tracking code)
  โ†“
Matomo Tag Manager container
  |
  โ†“
Matomo tracking tag
  |
  โ†“
Matomo server

This avoids having two tracking implementations running at the same time.

When should you leave it unchecked?

Leave it unchecked if:

  • You only installed the Drupal Matomo module.
  • You configured the Matomo site ID and URL in Drupal.
  • You want automatic page-view tracking.
  • You are not using Tag Manager.

Your flow should then be:

Drupal Matomo module
        |
        โ†“
Matomo JavaScript tracker
        |
        โ†“
Matomo server

Important: Avoid double tracking

A common mistake is:

  1. Enable Drupal Matomo tracking.
  2. Add Matomo Tag Manager container manually.
  3. Both fire.

Result:

  • duplicate page views,
  • inflated visitor counts,
  • duplicate events.

If you use Matomo Tag Manager, the recommended Drupal configuration is usually:

  • โœ… Enable the Matomo module
  • โœ… Enter Matomo URL + Site ID
  • โœ… Enable Tag Manager integration/container
  • โœ… Check Disable tracking
  • โœ… Let Tag Manager handle all tracking tags
Page Term Reference

Comments