How do I install Matomo tracking in Google Tag Manager (GTM)?
It’s easy to add Matomo tracking to your Google Tag Manager. This guide explains all required steps to get started, for both Matomo cloud customers and Matomo on-premise users.
If you are a cloud customer, you can use the built-in custom “Matomo Cloud Tag” to set up Matomo. Follow these steps:
- Login into your Google Tag Manager account.
- Select the container that you want to add Matomo to.
- Click “Tags” from the left menu.
- Click the “New” button at the top right corner of the tags section to add a new tag.
- Click on “Tag Configuration” to select the tag.
- A window with all the available tags will pop up, here click on the Discover more tag types in the Community Template Gallery link.
- In the search bar, search for “Matomo Tracking Tag for Matomo Cloud” and select the tag.
- Configure the tag by specifying the Matomo URL and Matomo IdSite.
- Scroll down and click on “Triggering”.
- Select “All Pages” to fire the Matomo tracking tag on all of your pages.
- Click “Save”.
- Preview your changes by clicking the “Preview” button.
- Check if the Matomo tag is firing as expected.
- Publish your changes by clicking the “Submit” button and then the “Publish” button at the top right.
Alternatively, cloud and on-premise users can follow the steps below to set up Matomo tracking with Google Tag Manager:
- Login into your Google Tag Manager account.
- Click “Tags” and then “New”.
- Click “Tag Configuration” and select “Custom HTML”
- Copy the standard Matomo JavaScript Tracking code:
- Log in to Matomo with your admin or Super User account.
- Click on the “Administration” (cog icon) in the top right menu.
- Click on “Tracking Code” in the left menu (under the “Measurables” or “websites” menu).
- Click on “Tracking Code” in the left menu.
- Click on “JavaScript Tracking” section.
- Select the website you want to track.
- Copy the tracking code.
- Paste this JavaScript tracking code in the Tag Configuration HTML field.
- Scroll down and click on “Triggering”.
- Select “All Pages” to fire the “Matomo tracking tag” on all of your pages.
- Click “Save”.
- Preview your changes by clicking the “Preview” button.
- Check if the Matomo tag is firing as expected.
- Publish your changes by clicking the “Submit” button and then the “Publish” button at the top right.
Congratulations! You have successfully set up Matomo tracking code via Google Tag Manager. To verify that hits are being tracked, visit your website and check that this data is visible in your Matomo instance.
To learn even more about using Matomo with GTM, we recommend this 3rd party article: Google Tag Manager and Matomo.
Did you know that Matomo also has its own Tag Manager? Learn more about the Matomo Tag Manager, or check out how you can migrate from GTM to MTM.