One Matomo Installation, 2 Domains, Two Tracking URLs?

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

It seems like it should be possible for me to point analytics.BBB.com to the same IP address, but IIRC I had to set up an HTTPS certificate for analytics.AAA.com 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" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (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 analytics.BBB.com; 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 analytics.BBB.com and analytics.AAA.com 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.

Hi,

My method is to point matomo.allofmy.domains.example 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 https://github.com/matomo-org/tracker-proxy to forward the data to one central Matomo server from all of your domains.

Thanks Lukas! That first solution worked for me.

1 Like