Multiple measurables / tracking IDs in one website?

Greetings, I’ve a question regarding setting up two or more “measurables” for a single website. Namely - is it possible?

If anyone else has faced this / similar issue, we’d love to know how you resolved it :slightly_smiling_face:

Some context below:

We utilize Matomo Analytics in our website, and wish to analyze both internal and external traffic flowing through the site within the Matomo-dashboard. Note that we do not wish to filter out internal traffic, only separate it for more granular analysis.

Initially we thought this could be achieved via Segmentation, by utilizing “visitor IP” as an identifier. It seems however that this utilizes stored IP-information, and our Matomo has IP-anonymization enabled, so we couldn’t use Segmentation-feature to reliably separate internal traffic.

This lead us to creating a new measurable within Matomo, with a separate tracking ID. This new measurable also includes our internal IP within its “excluded IPs”, with the idea being that it would only display external traffic. Not ideal, but good enough for our purposes.

It’s at this point we noticed issues. Our installation method was admittedly crude - we basically installed two tracking IDs within our site via our tag manager, so it ended up looking like this:

Tag 1:

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://matomo.org/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

Tag 2:

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://matomo.org/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '2']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

After installing this and monitoring the real-time visits log, we quickly noticed that the visits for our original measurable visits stopped trickling in, and trickled into the newly established measurable instead. It seemed as if the original measurable stopped working, so we quickly revert our Matomo installation to its previous state, with only the original measurable tracking ID present. Reverting the change fixed the issue, and data was flowing back to the original measurable.

We’re still wondering if there is a functional way of installing multiple measurable / tracking ID’s within a single website. We tried the usual searching / googling around, but didn’t find any results that corrolated to our issue at hand. Hence this thread :slightly_smiling_face:

I think you have to use only one script where you define two separate tracker like this:

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
   /* First tracker  */ 
    var u="https://matomo.org/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);

   /* Second tracker  */ 
    var secondaryTracker = "https://matomo.org/matomo.php";
    var secondaryWebsiteId = '2';
   _paq.push(['addTracker', secondaryTracker, secondaryWebsiteId]);

  })();
</script>
<!-- End Matomo Code -->

Now i use Matomo Tag Manager with two tag, one for each tacking ID and it seems work (I no longer use the code written above).

Hello luvmegrub and thanks Simone, you can find more infos about this matter here:

Scroll to: Multiple Matomo trackers
https://developer.matomo.org/guides/tracking-javascript-guide

1 Like

Hi @luvmegrub,

Another solution (in order to prevent the creation of a second measurable, and complex things in tracking), would be declare a custom dimension (eg. Internal Traffic with values True or False).
Then you just need to use segments to split the results. You can even compare all visits with internal traffic or external traffic…