One Matomo Installation, 2 Domains, Two Tracking URLs?

I have two domains ( and I already have Matomo installed and running for, specifically at I’ve added to be tracked through the web interface, but the Tracking Code sends events to I would prefer for BBB to send events to Is this possible?

It seems like it should be possible for me to point to the same IP address, but IIRC I had to set up an HTTPS certificate for and also hardcode this in the Apache server configuration.

Is there any way to configure this so that each site sends events to its own analytics domain, or am I out of luck?

Thanks in advance!

Do you use the MTM? Or are you doing your tracking with _paq only?

Just the tracking code, not the MTM.

So, sorry, I don’t understand the issue as the tracking code would be:

  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  (function() {
    var domain = '... something that will extract the domain from the page URL...';
    var u='https://analytics.' + domain + '.com';
    _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);

I’m not sure I understand.

I can easily modify the JS tracking code to point to; that’s not the issue.

Where I believe I need help is figuring out how to configure apache and matomo, plus appropriate SSL certificates, so that calls to and both go to the same IP, and are handled by the same Matomo installation.

I believe that AAA is hardcoded in a bunch of places on the server side (eg apache’s matomo.conf ServerName.

I apologize if I’m explaining this poorly, I don’t know much about either apache or matomo.


My method is to point to the same webserver running Matomo, there have it listen to all of these domains, add them as allowed domains in the config.ini.php and create one SSL certificate that is valid for all of these domains.

This is a bit manual and hardcoded as you mentioned, but I can’t think of any better way at the moment.

Of course if you only care about having the “nice” subdomain in the tracking request, you can use to forward the data to one central Matomo server from all of your domains.

Thanks Lukas! That first solution worked for me.

1 Like