<script src="https://.../container_ugas78d7sg.js">
<script src="https://.../container_asd3s99ssd.js">
and send events using this 2nd container. However both scripts want to load the tag manager in window._mtm
._mtm
?Can you maybe do e.g.:
<!-- Matomo Tag Manager -->
<script type="text/javascript">
var _mtm1 = window._mtm1 = window._mtm1 || [];
_mtm1.push({'mtm1.startTime': (new Date().getTime()), 'event': 'mtm1.Start'});
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src='https://{$MATOMO_URL}/js/container_{$CONTAINER}.js'; s.parentNode.insertBefore(g,s);
var d1=document, g1=d1.createElement('script'), s1=d1.getElementsByTagName('script')[1];
g1.type='text/javascript'; g.async=true; g1.src='https://{$MATOMO_URL}/js/container_{$CONTAINER}.js'; s1.parentNode.insertBefore(g1,s1);
</script>
<!-- End Matomo Tag Manager -->
I think you only need one _mtm in the whole window, since it only contains the startTime anyways. The only thing you need to do is to load the second container to the page, and they both will use the same "startTime" variable - I see no reason why those two containers should use different "startTime" variable.
What I'm not really sure is whether you should get the first or second element of the array during the getElementsByTagName
.
Hope it works!