Single page web app and data segmentation

I have a single page web application that is used by multiple users (in multiple tenants) and I need to track which logical part of the system the users are typically using.

The problem is that the URL does not change a lot and is made of UUIDs, so representing the data by URL is often pointless.

So I am thinking of using the “custom variables / dimensions” mechanism so that I add a useful context when the user switch from one part of the system to another.

But does that mean I would have to reload / reinitialise the Matomo stack each time the user change “page / tab / screen” (on the single page app) to pass a new custom variable? And if I have to do that (multiple inits) will Matomo cope with it?

The behaviour is clear when we talk of initial page load, but the documentation does not seem very clear on the behaviour in Single Page apps (i.e. when called multiple times).

Then when going into Matomo to see the stats, is there a way I could restrict specific users to specific “contexts” (i.e. a given custom variable/dimension value).

For info, these are some of the pointers I have been looking at:

But admittedly they don’t fill me with great confidence.

Thanks for your help.