@mkassir95 opened this Issue on November 3rd 2021

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

@peterbo commented on November 11th 2021 Contributor

+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 page1

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.

@sgiehl commented on November 11th 2021 Member

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?

@sgiehl commented on November 11th 2021 Member

@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.

@peterbo commented on November 11th 2021 Contributor

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.

@peterbo commented on November 11th 2021 Contributor

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:

time_on_page2

@tsteur commented on November 11th 2021 Member
@sgiehl commented on November 11th 2021 Member

@tsteur it's not a duplicate. #9198 is about the average metric, which is also wrong for a similar reason. This is about the time on page displayed is the visits log tooltips. The linked PR aims to fix that, even though it's not yet complete.

This Issue was closed on November 26th 2021
Powered by GitHub Issue Mirror