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

time on page in the popup #20214

Closed
matomoto opened this issue Jan 13, 2023 · 10 comments
Closed

time on page in the popup #20214

matomoto opened this issue Jan 13, 2023 · 10 comments
Labels
duplicate For issues that already existed in our issue tracker and were reported previously.

Comments

@matomoto
Copy link

matomoto commented Jan 13, 2023

Matomo Version: 4.13.0
Matomo Update History: 4.11.0,4.10.1,4.9.1,4.7.0,4.6.2,4.6.1
Matomo Install Version: Unknown - pre 3.8.
Latest Available Version: 4.13.0

I have seen a mistake by the "Time on page" popup in the real-time page by the last visit page, when the time on page is under 30 seconds (i think). I have a own 1 seconds heartbeat (ping) for the first 10 seconds and a matomo heartbeat with 10 seconds. The matomo script starts after a timeout of 1 second (prevent tracking of 0 seconds viewer).

Here by a visitor, there leave the page after visit 10 pages.
Time in first page popup: 21:10:52
Time in last page popup: 21:12:06
= 1:16
Last time: 21:12:06
Time on page: (1min 16s)
In the popup by the last page: 0s
matomo-time-on-page-x-actions

Here by a visitor, there leave the page after visit it. The Time on page is 10 seconds, but in the popup 0 seconds.
matomo-time-on-page-1-action

By another viewer with more than 30 seconds time on page in the last page is the "Time on page" greater than 30 seconds. I think for the calculation of the time on page in the popup there is a 30 seconds barrier?

Edit: A better example.

2 actions
Time on page: (1 min 16 sec)
Time in first page popup (below): 21:30:48
Time in last page popup (above): 21:32:00
= 1:12
The viewer was also 4 seconds on the last page.
matomo-time-on-page-2-action

By another 1 action viewer with time on page 13 seconds, there was 13 seconds in the popup. It is also not on all time a mistake/bug or a calc time barrier. Its difficult.

Edit 2:
Its possible not a 30 seconds barrier, rather 10 seconds, but it seems its not barrier, rather the firered pings in the first 10 seconds with a setInterval are ignored in the popup time on page calc and only the matomo heartbeat (10 seconds) are in use of the time calculation in this case. But also this is not really the cause. Its difficult.

@matomoto matomoto added Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. To Triage An issue awaiting triage by a Matomo core team member labels Jan 13, 2023
@bx80
Copy link
Contributor

bx80 commented Jan 15, 2023

Thanks for the feedback @matomoto,

From my understanding of https://developer.matomo.org/guides/tracking-javascript-guide#accurately-measure-the-time-spent-on-each-page a heartbeat timer of 10 seconds, eg. _paq.push(['enableHeartBeatTimer', 30]); would mean that only visits of 10 seconds or more on the last page of the visit would record a non-zero "time on page" value.

Does this behaviour change for you with a lower heartbeat timer value?

@bx80 bx80 added the Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users. label Jan 15, 2023
@matomoto
Copy link
Author

matomoto commented Jan 16, 2023

Hello bx80,

i have a very custom matomo tracking code with own settings. For example, the matomo script is loaded first after 1 second timeout with a setTimeout. This prevents the tracking of 0 seconds views. It is to prevent littering my matomo database. The next is a own heartbeat with a setInterval for the first 11 seconds each second, also with a clearInterval.

var myheartbeat = setInterval(function() {
  _paq.push(['ping']);
}, 1000);
setTimeout(function() {
  clearInterval(myheartbeat);
}, 11000);

With this tracking code i see the time on page in the first 10 seconds (except the first second) more detailed as default. I see also 1 or 2 ... 9 ... 10 second/s time on page values.

Then i have a regular _paq.push(['enableHeartBeatTimer', 10]);.

With a

window.addEventListener('beforeunload', function(e) {
  _paq.push(['ping']);
});

i see also more detailed time on page after 10 seconds.

I have observed, that the "Time on page" in the popup is <11 = 0, like a:

var time_on_page = get_time_on_page();
if (time_on_page < 11) {
  time_on_page = 0;
}

@heurteph-ei
Copy link

Looking the screenshots, it seems just the last page duration is not taken into account.
In @matomoto first example, the last page time seems to be 2 seconds, but is displayed 0 (21:12:06 - 21:10:52 = 00:01:14) because total visit duration is 00:01:16
In the second example, 21:32:00 - 21:30:48 = 00:01:12. Then the last page duration is 4s. Maybe the page calculation is set only when another page comes after? But the visit duration is well calculated... 🤔

@matomoto
Copy link
Author

matomoto commented Jan 17, 2023

Looking the screenshots, it seems just the last page duration is not taken into account.
Maybe the page calculation is set only when another page comes after?

Not really.
The "Time on Page" in the black popup is "0 seconds", when the Time on page is <11 seconds.

Example: I have by visits with 0 actions and a regular "Time on Page" = 10 seconds a "Time on Page" in the black popup with "0 seconds". With regular 11 seconds, in the popup also 11 seconds. All lower than 11 seconds is 0 seconds in the black popup. That is the situation i observed.

The problem: I don't see, how much time on page is in the last page, when it is lower than 11 seconds. By 0 actions, is see the time on page in the regular box - here it is not a problem. By many pages in one visit i must self calculated the time on page for the last page, when it is lower than 11 seconds.

@heurteph-ei
Copy link

heurteph-ei commented Jan 17, 2023

The problem: I don't see, how much time on page is in the last page, when it is lower than 11 seconds.

Maybe in this case this is the difference between Visit duration and time between last and first page...
In case of last page duration > 10 seconds, my operation (VD - (TLP - TFP)) true or false?

@matomoto
Copy link
Author

Hello heurteph-ei,
is this a question to me?

The Time on Page calculation in the last page is OK by greater than 10 seconds. My question is: is there a time barrier in the calculation that makes <10 = 0 ? Because that is the fact i observed.

@heurteph-ei
Copy link

@matomoto, yes the question was for you 😉
Then is seems the total visit duration is well calculated any time, but the last page duration is not set when < 10...
How are configured default_time_one_page_visit? (not sure it could impact your problem...)

@matomoto
Copy link
Author

global.ini.php

default_time_one_page_visit = 0

untoched. And i don't touch it, because it manipulates the real Time on page. Consider myheartbeat above.

@MatomoForumNotifications

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

https://forum.matomo.org/t/0-sekunden-aufenthaltsdauer-pro-url/49486/2

@sgiehl sgiehl removed the To Triage An issue awaiting triage by a Matomo core team member label Feb 9, 2023
@sgiehl
Copy link
Member

sgiehl commented Oct 9, 2023

After checking this one again, I think it's actually a duplicate of #9539
The time on page for the last page currently isn't set correctly even when using a heatbeat timer.

@sgiehl sgiehl closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2023
@sgiehl sgiehl added duplicate For issues that already existed in our issue tracker and were reported previously. and removed Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users. Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate For issues that already existed in our issue tracker and were reported previously.
Projects
None yet
Development

No branches or pull requests

5 participants