I am tracking events and pages , matomo is calacating the time spent on each page as the difference between the last event done on the page and the next page view and not the difference between the two page views. How to solve this
+1 - Time on page is currently calculated incorrectly on pages that trigger events or site searches (and probably others like outlinks). The time on page timer should only be stopped by another pageview.
Time on page should be 14s here, because the second pageview happened 14s after the first one. But it is only 1s, because the timer is stopped by (in this case) the site search. The exact same behaviour happens with events.
That indeed sounds like a bug. @peterbo Are you able to say if that only has effect on the visits log, or is that also the case for the overall time one page calculation you can see in the pages reports?
@peterbo Had a quick look at the visits log implementation. This might possibly fix it: https://github.com/matomo-org/matomo/compare/vlogtimeonpage
But I'm currently not able to finish that PR by adding some tests as my time is quite limited. Will try to finish that another time if no one else is able to pick that up till then.
That indeed sounds like a bug. @peterbo Are you able to say if that only has effect on the visits log, or is that also the case for the overall time one page calculation you can see in the pages reports?
That's a good question. It definitely reflects the wrong behaviour in the link_visit_action table (time_spent_ref_action), but perhaps the archiver uses another logic. I'll check later in a smaller instance and replicate this.
That indeed sounds like a bug. @peterbo Are you able to say if that only has effect on the visits log, or is that also the case for the overall time one page calculation you can see in the pages reports?
Luckily, it looks like it doesn't affect the calculation of the pages report "avg. time on page", but just the display within the Visitor log:
Is this a duplicate of https://github.com/matomo-org/matomo/issues/9198 ?