I know I can track to another Matomo Server with “addTracker” … but how is it possible to track into 3 different Matomo Servers (or Websites within 1 or 2 Matomo Servers)?
we got some JS Scripts which inject 360° Panoramic Images into our Customers Websites, also we got some JS Scripts which inject Maps with those Panoramic Images into their Websites.
Example:
User A already got a Matomo Tracker on their Page - tracking their Stats.
They include our Pano Images JS - I add another Piwik Server with “addTracker”
They also include out Maps JS - I need to add just another Tracker to our Piwik Server with another Website ID …
…
btw) is it possible to “setDocumentTitle” per Tracker? As I want to add something for the “viewer” and another Info to the “map” tracking … also the trackPageView should only be executed for our newly added Tracker - and not all 2 or 3 Instances?!? (according to Matomo Blog: Say you call _paq.push([‘disableCookies’]); _paq.push([‘trackPageView’]);, then both methods will be called on all tracker instances assuring they will behave the same and will track the same data into both Matomo websites.)
You can call “addTracker” multiple times to track into as many instances as you want. In the past there was a notice logged when calling this method multiple times but it has been fixed in the latest beta AFAIK
ok wasn’t that easy … as piwikAsyncInit got overwritten by seconds/third include of JS scripts for different Panos on same Page … but I guess now I got a working solution with window.onload Functions, Functions for piwikAsyncInit calls and so on, …
In case someone is interested how I solved it / got same Usecase - I made a quick Test-Page with my implementation here: Multiple Matomo Testcase
On Page Footer there are 2 Matomo Trackers added by CMS
Within the viewer.js.php the Tracker for the Viewer is added
Within map.js.php the Tracker for the Map is added
If there already is an existing Matomo Object - I use it and simply add my own with getTracker()
If there is no Tracker - I load Matomo JS and create one
Actions within Viewer/Map are also tracked in the respective tracker …
So I guess this implementation should work regardless if there is Matomo used on the Site where my Panos get loaded or not …
Hey @Yann_Poirot,
if I’m in control for loading the JS - this would be a nice approach - but my Scripts can be included in 3rd Party Websites where I have no control what and when they load it … sometimes they Load Matomo in the Header (so before my Script is included), sometimes they Load it in the Footer of the Page (after my Script is included) and sometimes there is no Matomo at all