Matomo on 2 servers

I tried to get the Matomo Joomla! plugin to send data to 2 (two) different servers.
Nr. 1 is the “real” server for collecting data
Nr. 2 is for educational purpose
Only 1 of the servers is recieving the data from the website.
What am I doing wrong?

I have found the following code on your website to put in the plugin and did set that up:

<script type="text/javascript">
  var _paq = window._paq = window._paq || [];

  (function() {
    var u="//https://www2.[domainname].nl/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '12']);

    // Add this code below within the Matomo JavaScript tracker code
    // Important: the tracker url includes the /matomo.php
    var secondaryTrackerUrl = 'https://live.[domainname].nl';
    var secondaryWebsiteId = 3;
    // Also send all of the tracking data to this other Matomo server, in website ID 77
    _paq.push(['addTracker', secondaryTrackerUrl, secondaryWebsiteId]);
    // That's it!

    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);

Does Anyone have an idea?

“/” on the end of the url.

var secondaryTrackerUrl = 'https://live.[domainname].nl/'; // "/" on the end
// ...
_paq.push(['addTracker', secondaryTrackerUrl+'matomo.php', secondaryWebsiteId]);

More infos:

1 Like