What is your strategy for Matomo + MTM?

Hei,

What is your strategy? Should I have the Matomo analytics code, PLUS, the Matomo tag manager on my website, or should I have only MTM and have MA as a tag of it? If the latter is the way to go, how do I configure the tag? I could not find an example of configuring a tag for MA in MTM.

Thanks

If you want to use MTM (that is easier and very flexible), then you just have to put the following code in the page head:

<!-- 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://matomo-server/js/container_id-container.js'; s.parentNode.insertBefore(g,s);
</script>
<!-- End Matomo Tag Manager -->

And that’s it!

So what you are saying is that with MTM and this code snippet everything works as if it is the analytics script code?

Then you just have to publish the container (see id-container in my previous code) in MTM…