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:
- Enable Drupal Matomo tracking.
- Add Matomo Tag Manager container manually.
- 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
Comments