First of all, Kudos to Matomo community for such awesome analytics tools.
I am using Matomo for tracking page view. I have a requirement where on completion of XHR request of track page view I need to perform some operation which involves accessing xhr ( XmlHttpRequest ) object. Basically, I need some of the data extracted by Piwik to be sent to another server too. I figured out that with trackPageView() we can pass customTitle, customData, callback . I was able to pass a callback function as a parameter but I am not able to access xhr in the callback.
Is there some way I can access xhr in the callback function or extract data using some other method?
I’m really not sure. I would avoid wherever possible modifying any of the core Matomo js.
The reason I suggested to use multiple trackers would be to receive whatever data you need based on the Request object from the second tracker by creating your own piwik.php and print_r($_REQUEST). I’m not sure if what you’re after will be in there, but that would be my approach.