How to use different containers from different environments for an element existing in different environments?

Question related to matomo tag manager
So, when you need to listen for some event on an element you will grab the id of the element and create a trigger for it.

My app has two UIs (player and author) and the same two environments in the matomo. How does matomo tag manager should know which UI user is using making that event (player and author) and which trigger (from player ui env in the matomo or the author) it should run ?

So as an example I have a button which I should track by the clicks. That button exists both in the Player UI and the Author UI. I don’t have .env file for each UI because user manages UIs inside the app itself so I can not dynamicly put certain containerID in the script inside index.html file.

My idea is to put two containers in our index.html file. One is gonna be for Player and the second one is gonna be for Author UIs.
The problem is if we have two containers and one element with single static id attribute how does matomo tag manager should know which trigger to run, from author or player for example?
In that case we would need to create ids for our elements dynamicly (some-element-id-player or some-element-id-author), so that way tag manager will trigger the right element’s ids.

But is there some better way to do it?