Drupal is an open-source content management system (CMS) used for building and managing websites. You can integrate Matomo with Drupal (version 9 to 10) using a community developed plugin, which now supports Matomo Tag Manager.

Integrating Matomo with your Drupal pages enriches insights into visitor interactions, content performance, and website/app performance. This helps optimise content effectiveness, conversion drivers, visitor experiences and more! Before tracking, ensure compliance with data protection regulations by obtaining user consent where required.

Requirements

Before proceeding, ensure you have the following in place:

  • New Users: Create your Matomo account (Cloud or On-Premise).
  • Current Users: You have superuser access to add a new measurable to an existing Matomo instance.
  • A Drupal admin account with configured pages.
  • Download the plugin.

Install the plugin

  1. Open the Drupal administration page and click on Extend in the top menu.
  2. Click Add New Module and Choose File to locate the downloaded plugin file.
  3. Select the file and click Continue.
  4. When the module is added, choose to enable newly added modules or go to Extend > Statistics and select the Matomo Analytics modules to install. If using Tag Manager, select both modules; or if you are using the tracking code instead, then you only need to install the top Matomo Analytics module.

drupal matomo plugin install

Configure Matomo tracking

  1. In Drupal, go to Configuration > Matomo Analytics to set up your tracking.
  2. Enter the Matomo site ID your Matomo instance URL (e.g., https://mysubdomain.matomo.cloud/) in the Matomo HTTPS URL field.
  3. Ensure mandatory fields are completed.
  4. To customise tracking, modify the Tracking scope, Custom variables, and Advanced settings as needed.
  5. Click Save Configuration.

If you are not using Tag Manager, skip the section below and go directly to testing and validating the configuration.

Integrate with Matomo Tag Manager

If the Matomo Analytics Tag Manager module is activated in Drupal, you can enter your Matomo Tag Manager container details directly in the plugin interface. Once added, manage and customise tracking within Tag Manager by configuring tags and triggers without modifying your Drupal site’s code.

  1. In Drupal, go to Configuration > Matomo Analytics and click on the Tag Manager containers tab.
  2. Click Add container and provide a Label (name) and your Container URL. The URL is found in the Tag Manager code snippet of your published container, e.g., https://cdn.matomo.cloud/mysite.matomo.cloud/container_AbC123xY.js)
  3. Click Save.

drupal plugin integration

After adding the container, proceed to test and validate your configuration.

Manually embed the Matomo tracking code in Drupal pages

An alternative to using a community developed plugin, is to manually add the Matomo tracking code or Tag manager code to every Drupal page you want to track.

  1. Open your Drupal site editor.
  2. Go to Content where your site’s pages are listed.
  3. Click Edit on the relevant page to add the tracking code.
  4. Set the Text format as Full HTML and click on the Source button.
  5. Paste the tracking code into the page, keeping the script tags.
  6. Click Publish to save the changes.

matomo drupal 10 integration

Validate the Integration Configuration

Validate the integration by verifying that tracking is active and data is being sent to Matomo as expected. When testing, make sure tracking is not blocked by consent settings, ad blockers, or browser privacy features.

  1. Open your Drupal website and visit the page containing the tracking code to test if Matomo captures your visit. 
  2. Navigate to your Matomo dashboard and view the Visits in real-time widget to verify your website visit appears in the log.
  3. Use the browser’s developer tools > Network tab and filter for matomo.php, which indicates tracking requests are being sent. 
  4. For integrations using Tag Manager, confirm the Matomo Configuration Variable is correctly defined. Use the Preview and Debug tool to ensure the trigger fires as expected and activates the tag.

Troubleshooting

If no tracking data appears in Matomo, use the following resources to troubleshoot:

Next steps 

For reporting and advanced tracking configurations, explore related topics:

Discover additional resources in the knowledge base, developer guides and community forums

Happy Analytics!

Disclaimer: The use of any third-party tools (plugins, extensions, platforms, APIs, widgets, etc.) is at your own risk. Matomo does not own, control, maintain or support any third-party tools that integrate with our product. We recommend checking your privacy setup is correctly configured across your environment when using any third party tools.

Previous FAQ: How do I manually insert the Matomo tracking code on WordPress?