Be able to track different data on different instance

We have a special usecase where we want to instantiate 2 different trackers that will push different data to different matomo instances. We need to address 2 scenarios:

1/ we want to be able to manage non regression tests with live traffic.
So we will use 2 versions of our tracking library on the same domain.
Test library will push data to the test instance, with test formated data
Prod library will push data to the prod instance, with prod formated data.
And we will compare the 2 to be sure that changes are expected.

Today, all matomo trackers are using the _paq object. So both test and prod data will go everywhere. Which is not what we aim to.

2/ our clients from time to time are subscribing to other tracking agencies that can also use Matomo.
So the data that will be pushed by us, or by the other agency are totally different and must not mixup.

Technically, it means that when instantiating the tracker, we should be in the position to state which datalayer will hold the data, like what GTM is doing. Alternatively, like what is done in GA4, we should be in the position to tell to matomo where to route the request each time we push data into the _paq array.

Any of the solution would work for us. But unless i’m wrong none is possible today, except tweaking the code of matomo with a nasty search replace of _paq object. And even this replace would not work if you are using cloud version of matomo, or if you have just 1 instance (with 2 siteId for test and prod for instance).

what do you suggest ?

Hi @gorfo

Did you try Matomo Tag Manager? it is like GTM, and can manage different version of tracker (test, production, etc.)
With this, you can also mix several tracking rules if your site declares 2 different MTM containers…