Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript tracker can send tracking API requests as bulk for better performance #4910

Closed
mattab opened this issue Mar 26, 2014 · 7 comments
Closed
Labels
c: Performance For when we could improve the performance / speed of Matomo. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.

Comments

@mattab
Copy link
Member

mattab commented Mar 26, 2014

There are cases where on the same page one user may call trackPageView() multiple times, or even trackPageView, trackEvent, trackEcommerceOrder, etc.

in these cases in the Piwik.js request handler queue, we should be a bit clever and detect there are several requests queued. Then we send these requests as bulk.

Advantages:

Follows up the bug in #4909

@mattab
Copy link
Member Author

mattab commented Mar 26, 2014

For example in this documentation: http://piwik.org/docs/ecommerce-analytics/#tracking-ecommerce-orders-items-purchased-required

we recommend the following (currently):


_paq.push(['trackEcommerceOrder',
.....
]);
_paq.push(['trackPageView']);
[...]

so the idea would be to bulk those two requests in one bulk request.

@mattab
Copy link
Member Author

mattab commented Mar 26, 2014

we need to pick a timer delay (eg. 100ms), the piwik.js queue will wait for this timer to "collect" other pushed requests, and then will send as bulk if there is more than one queued.

@mattab
Copy link
Member Author

mattab commented Sep 26, 2014

Note: in Contents tracking plugin Thomas used this technique to send a bulk request. This was done in: 774611a

See piwik.js tracking function function sendBulkRequest(requests, delay) {

@kachkaev
Copy link

After a few experiments with piwik, I can confirm that the bug still exists. When a mix of events and page visits happen nearly simultaneously, it is likely that they are put to the database in the wrong order. The issue seems to be simply caused by different speeds of HTTP requests. Having that sendBulkRequest() already exists in piwik.js, how difficult would it be to fix the processing of a set of _paq.push() calls? The source code appears to have all necessary components, the only thing needed is to throttle the activity behind _paq.push().

I'm new to piwik, so I'm afraid I'll be only able to implement some dirty solution if any at all. If anyone knowledgeable in piwik.js sees this, your help will make a real difference. Hope it's an easy pick.

@mattab mattab modified the milestones: Long term, Mid term Dec 23, 2015
@mattab mattab modified the milestones: Long term, Mid term Dec 5, 2016
@mattab
Copy link
Member Author

mattab commented Jun 19, 2017

At this point it seems better not to implement this feature, as otherwise it would lead to many POST requests to the Tracking API which is not desired because it would prevent us from Replaying the tracking requests later on, in case of a Piwik server problem. Wont fix.

@mattab mattab closed this as completed Jun 19, 2017
@mattab mattab added the wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it. label Jun 19, 2017
@MatomoForumNotifications

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/javascript-react-bulk-sending-events/50498/1

@sonnd08
Copy link

sonnd08 commented Mar 14, 2024

@mattab What if we store client time for each event and send to Matomo? So we still only need 1 POST request but the time still correct.

Also I would like to have a setting to define which event will not being put in bulk request (Example with purchase event, it better being sent immediately instead of waiting for a delay and user close page before events could be sent)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

4 participants