In this guide, I will walk you through the installation process and provide step-by-step instructions to ensure a seamless deployment of your first container using Matomo Tag Manager. So, let’s dive in and get started!
Installation
Setting up the container may vary in complexity depending on the type of website you have or the content management system (CMS) you are using. To obtain the JavaScript container, follow these simple steps:
- Access the Matomo Tag Manager interface on your website.
- Locate the “Install Code” option, which can be found at the bottom of the left column on the page.
- Click on “Install Code” to generate the container.


The container represents the JavaScript code that governs all the tags you wish to incorporate using Matomo Tag Manager. It is imperative to have this container code present on all pages of your website to ensure effective control over the pages through Matomo Tag Manager.
The snippet looks like this
<!-- Matomo Tag Manager -->
<script>
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://www.yourwebsite.com/wp-content/plugins/matomo/app/../../../uploads/matomo/container_1239abc23.js'; s.parentNode.insertBefore(g,s);
</script>
<!-- End Matomo Tag Manager -->
Once you have obtained the container, copy the provided JavaScript code. It is highly recommended to place this code within the <head> section of your website. Here is this process using WordPress as an example:
- Access the backend of your WordPress site.
- Navigate to the theme editor section. Note that directly modifying the theme may not be the best practice. It is advisable to use the Matomo plugin to insert the tracking code (see below).
- Locate the appropriate section where you can insert the tracking code. In most cases, it is ideal to place it just below the closing </head> tag.
- Paste the Matomo Tag Manager container code in the designated location.
- Save the changes to your document.
Alternatively, simply go to Matomo “Tracking” settings in your WordPress Admin and select “Tag Manager” as tracking mode. Save the changes. For Matomo to track you will need to add a Matomo Tag to the Tag Manager container. It otherwise won’t track automatically.

By following these steps, you should have successfully inserted the container code into your WordPress site. To confirm if the installation was successful, refresh any page of your website and inspect the source code.
Congratulations! You have successfully learned how to copy and paste the Matomo Tag Manager container code onto all the pages of your website. It is essential to have this container code present on every page to ensure the proper functioning of Matomo Tag Manager.
As an exercise, I encourage you to deploy your first container on a test website. This will allow you to familiarise yourself with the process and ensure a seamless deployment across all pages.
Remember, Matomo Tag Manager offers a powerful solution for managing tags and optimising your website’s performance. By implementing it correctly, you can gain valuable insights into user behaviour and enhance your overall tracking capabilities.