Custom app/plugin tracking

I would like to use Matomo in an app that different websites use. Lets call it MyApp.dom

Websites use it and may publish several of them so i need to know what i can do to:

    • track based on the website that is being tracked. Ie if a website calls then Matomo is loaded and i need to track interactions based on the actual website not only as a myapp interaction
    • as there can be multiple apps not only point 1 info needs to be available but also i need to know how i can print and or send an extra piece of info as to what the id of the actual app instance is.
    • any chance i can query this info separately so i can then create separate dashboards for each website?

Hi @bizmate
(sorry, point 2 is not very clear…)
How is integrated your MyApp? iframe? webpart? just an API?

Currently Iframe but in the future these could be server side rendered or though JavaScript

In iframes, JavaScript context is separated from the main document, then you won’t have any conflict between 2 apps in the same page, or event between your app and the main app…
With JavaScript rendering, I suggest you track with the low level HTTP API. Then you won’t have any conflict with other parts of the application.

Do you have any examples on how both would work?
Also what about point 3?

For instance I received a suggestion that I could customise the SITE ID

_paq.push(['setSiteId', '{{ MATOMO_SITE_ID }}']);

So can i send custom info, ie

_paq.push(['setSomethingCustom', '{{ CUSTOM_SITE_ID }}']);
_paq.push(['setSomethingCustom', '{{ APP_ID }}']);

In case of iframe, no problem, this will work well.
In case of injected DOM via JavaScript, if Matomo is also used in the app host, all events will be sent to all Matomo instances…
The I suggest the low-level calls:

Thank you for the reply. Just to confirm

is there a way to customise what data is sent so that then i can use it for the splitting of the data? ie

I understand i can do
_paq.push(['setSiteId', '{{ MATOMO_SITE_ID }}']);

however i need to pass more than one id. One is lets say the site ID and the app id.

These are dynamic, ie i dont set them up on Matomo first. They are set up in the application and used by the website to call the application. For instance is called when the Iframe is called in the original website

When this is done i can use the referred to identify the site, but also i want to pass this someUID to Matomo

hence my previous example of …

_paq.push(['setSomethingCustom', '{{ CUSTOM_SITE_ID }}']);
_paq.push(['setSomethingCustom', '{{ APP_ID }}']);

Basically can i do this custom tracking?

And again can i then query the data so that i can split it based on these values ?

I am still unclear in what is the best way to send custom information on page load to Matomo.

Unfortunately I have received no reply to my previous message and I have also looked at custom dimensions.

It looks like custom dimensions and events could be a bit redundant of each other. So going back to my questions what is the best way to report custom information on page load?

Custom dimensions, events or other?