Can I use the same tag manager container?

Can I use the same tag manager container for more then 1 website? So I don’t need to implement two different scripts.

I have read on this web page but I don’t understand how to do it https://matomo.org/faq/tag-manager/how-do-i-track-my-staging-dev-production-websites-automatically-using-the-same-tag-manager-container/. Should i create a lookup table for every tag manager container or how can i use the variable?

Do you need to track in the same siteId?

Yes, that’s my thought. For example one without internal traffic and one with.

Sorry, I don’t understand:
At my question “in the same siteid” you replied “yes”
and after “one without internal traffic and one with” that I understand as “no”

Sorry, wrong answer from me.

I want to use the same container for two different siteids with the help of lookup table: https://matomo.org/faq/tag-manager/how-do-i-track-my-staging-dev-production-websites-automatically-using-the-same-tag-manager-container/.

As described in the doc, you can use some MTM variable to select the SiteID.
And this variable can be configured by the MTM datalayer or by a JavaScript function (eg that could read the URL and deduce the siteId form it), or a JavaScript global variable, etc.
So: yes, you can use the same MTM container for several sites.

Nice, but how do i set it up for the another website? I can set it up for siteid 1 and then when I am going to use the same setup for siteid 2 how do I do that?

Easiest way:

Javascript MTM bootstrap code

<!-- Matomo Tag Manager -->
<script type="text/javascript">
var matomoContainer = 'https://matomo-server/js/container_aA0bB1cC.js'; // You must set the MTM container URL here
var siteId = 1; // You must set the site id here
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
_mtm.push({'siteId', siteId});
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=matomoContainer; s.parentNode.insertBefore(g,s);
</script>
<!-- End Matomo Tag Manager -->

Matomo siteId Variable

(You have to create it):

Matomo configuration Variable

(You have to create it):

1 Like

Alright but thats not according to the documentation I linked to. Then i would create a lookup table for each site in matomo, I guess.

I think you can make use of it