@adityasharma7 opened this Pull Request on November 2nd 2018

implements #13662

@tsteur commented on November 2nd 2018 Member

@adityasharma7 be still good to describe your use case to better understand things. And be aware that if image get request is used, the xhr may not be set.

@adityasharma7 commented on November 2nd 2018

@tsteur Thanks for your quick response.
As stated on the issue we have another non Matomo system and when we track any page with Matomo some of the data extracted by Piwik.js will also be sent to a different system that may be able to give a quick glimpse about the tracking.
I explored about the getImage() method, it overrides onload so xhr object is there in that case. Though, thanks for pointing that.

@tsteur commented on November 4th 2018 Member

Cheers, so it is mainly the request url you are interested in? The PR looks good and can be merged, it's just to understand the use case so I can check if there's maybe a better way to do it that ensures better backwards compatibility in the future etc.

@adityasharma7 commented on November 5th 2018

Yes, exactly only the request url

@tsteur commented on November 6th 2018 Member

Could we maybe pass request then? This way it would also work in getImage() method for example.

@tsteur commented on November 8th 2018 Member

In Matomo 3.8 we're adding better support for sendBeacon and it can be used by default see https://github.com/matomo-org/matomo/pull/13451/files#diff-1279d666063b65e6d6777f902d11574fR3766 . As there is no XHR object, we need to pass request url instead in the callback so it works for all kind of methods.

@adityasharma7 commented on November 9th 2018

Indeed, request seems a much better solution.

Though I found another way which I am uncertain of a right solution. There is a method getRequest() available with piwikTracker which can be called in the callback. I can get all the parameters except the page title. I digged further, as it is a generic method the request string is initialized with specific parameters for various applications.

Is it the right way? If no I can use the above method till the changes you suggested are available with the release. if yes, we won't need a change.

Looking forward to Matomo 3.8 with https://github.com/matomo-org/matomo/pull/13451/files#diff-1279d666063b65e6d6777f902d11574fR3766 :)

Thanks for sharing that.

One more thing came to my mind what if we make another tracker and use it to send the request to a non matomo server, is it a valid solution?

@tsteur commented on November 11th 2018 Member

Calling getRequest would work to get all the parameters (it wouldn't include the idgoal=X though when you track a goal). I just realize it seems there is no getDocumentTitle available which be useful to add. Also realising it would be actually great to pass the tracker instance in the callback as first argument... then optionally we could also pass request variable.

@adityasharma7 commented on November 13th 2018

I just realize it seems there is no getDocumentTitle available which be useful to add.

+1. I will see if I can contribute.

Also realising it would be actually great to pass the tracker instance in the callback as first argument... then optionally we could also pass request variable.

Sounds promising. I will update the code soon

Powered by GitHub Issue Mirror