Matomo from any domain

Hello, I have my own js library which I distribute to users and they adds it to their pages via script tag, then this script adds an iframe(with my site) to the user site.
So I want:

  1. Add matomo logging to to the user site to know which methods of my library was called on the user site. How can I do it?

  2. Also I want to treat opening iframe(with my site, with matomo js also) as the same session(visit) which was started on the user site. Is it possible?

Hi,

I can’t say much about the implementation (apart from that it should probably work like you imagine), but want to mention that you should pay a lot of attention to privacy if you do this. It is really easy to send data you don’t control (and which will contain private information) to your server and be in violation of tons of privacy laws. You also need to be really transparent with your users if you are planning to do this. You might want to not use the matomo.js, but instead send your own requests to the Matomo tracking API to make sure no more data than absolutly needed is sent.