When you open Matomo for the first time, you will have the code shown to you. Otherwise, you can go to the Dashboard to have the code inside the <!-- Matomo – > comment tag, and go to the Tag Manager to get the code inside the <!-- Matomo Tag Manager – > comment tag.

<!-- Matomo -->
  <script type="text/javascript">
    var _paq = window._paq = window._paq || [];
    /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    (function() {
    var u="https://YOUR_CLOUD_DOMAIN.matomo.cloud/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.src='//cdn.matomo.cloud/YOUR_CLOUD_DOMAIN.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
    })();
  </script>
<!-- End Matomo Code -->


<!-- Matomo Tag Manager -->
  <script type="text/javascript">
    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.type='text/javascript'; g.async=true; g.src='https://cdn.matomo.cloud/YOUR_CLOUD_DOMAIN.matomo.cloud/YOUR_CONTAINER'; s.parentNode.insertBefore(g,s);
  </script>
<!-- End Matomo Tag Manager -->

Creating a Container in Matomo

After doing all the prerequisites, it is time to move on to the Tag Manager Configuration. First of all, you will need to add a Container.

Go to Tag Manager and then on the left side of the screen click on Manage Containers. You will be greeted by the following page:

Follow the arrow and click Create New Container. Fill in all the information with the values that you desire.

After creating the Container, you will be redirected to the Container’s page

On this page you will have all the information about your Tags, and you will also have access to the Container Menu on the left side. If you didn't add yet your Matomo Tag Manager Code, go to Install Code and copy the code snippet that they show there and put it under your Matomo code

After doing this, we can proceed with the next step.

Adding a Service - Google Analytics Example

The final part now is to create two test tags, we will create two Google Analytics Tags. A Custom-HTML Type and a Google Analytics (Universal) type. But before that, we will need to create a Variable and a Trigger.

After creating the variable and the trigger, we can proceed to creating the tags. For the Tags, we will create one that will contain the Google Analytics Code and other Tag Containing your UA Tracking Code.

After creating everything, you can publish your Matomo changes and then go to the browser and test the command _mtm on the console which will give you a similar result to this (depends on your DPS)

Do you need further help?

How can I get help with technical questions?