How to push a specific event on several Matomo website ids?

Hi,

I have 20 different Wordpress websites. Each website redirects to the same Booking website on which I have Ecommerce events.

I want to have :

  • one Global view for all websites + booking website (contain Ecommerce events)
  • one Specific view for all wordpress webite
  • one Specific view for the booking website (contain Ecommerce events)

So, I’ve create a Matomo website id = 1 for the global view.
Then, on all pages of all wordpress website and booking website, I push the following code :

<!-- Matomo -->
<script type="text/javascript">
  var _paq = window._paq = window._paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//{$MATOMO_URL}/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', 1]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

Then I have created a new Matomo Website id = 2 for one wordpress website.

On all pages of this wordpress website, I push the following script :

<!-- Matomo -->
<script type="text/javascript">
  var _paq = window._paq = window._paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//{$MATOMO_URL}/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', 2]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

=> So I have two different Matomo configuration for the same page on the same website.
As I can see it’s not working because Matomo will select only the last or the first pushed for assigning following events to website ids.

Is there a way to do what I want in a clean way ?

Thanks a lot !

Christophe