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:

  1. Login into your Google Tag Manager account.
  2. Select the container that you want to add Matomo to.
  3. Click “Tags” from the left menu.
  4. Click the “New” button at the top right corner of the tags section to add a new tag.
  5. Click on “Tag Configuration” to select the tag.
  6. A window with all the available tags will pop up, here click on the Discover more tag types in the Community Template Gallery link.
  7. In the search bar, search for “Matomo Tracking Tag for Matomo Cloud” and select the tag.
  8. Configure the tag by specifying the Matomo URL and Matomo IdSite.
  9. Scroll down and click on “Triggering”.
  10. Select “All Pages” to fire the Matomo tracking tag on all of your pages.
  11. Click “Save”.
  12. Preview your changes by clicking the “Preview” button.
  13. Check if the Matomo tag is firing as expected.
  14. 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:

  1. Login into your Google Tag Manager account.
  2. Click “Tags” and then “New”.
  3. Click “Tag Configuration” and select “Custom HTML”
  4. 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.
  5. Paste this JavaScript tracking code in the Tag Configuration HTML field.
  6. Scroll down and click on “Triggering”.
  7. Select “All Pages” to fire the “Matomo tracking tag” on all of your pages.
  8. Click “Save”.
  9. Preview your changes by clicking the “Preview” button.
  10. Check if the Matomo tag is firing as expected.
  11. 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.