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

Heart beat should count only the time that was actively spent on a page #9540

Open
tsteur opened this issue Jan 18, 2016 · 5 comments
Open
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@tsteur
Copy link
Member

tsteur commented Jan 18, 2016

So far, whenever we send a ping request from the heart beat feature, we set the log_visit.visit_total_time by calculating current timestamp - timestamp of first action. The time spent on the last action is calculated by calculating timestamp of last ping request - timestamp of last action creation.

This means we actually do not track how long a visitor spent actively on the page.

For example you open a new page in a new tab, 29 minutes later a visitor actually opens this tab, we send a ping request and we calculate a time spent on page of 29 minutes even though it is actually only a few seconds. On the contrary if a user opens the tab 30.01 minutes after the last action was tracked we would say there was actually 0 seconds spent on this tab because the pause between the last action and the ping request was > 30 minutes because it would otherwise create a new visit.

Another example: You're browsing on a page for 2 minutes and then work in another window. So far Piwik would correctly report "2 minutes". Now the user comes back after 29 minutes, we would send a ping request and Piwik reports "31 minutes" spent on this page even though it would be still only 2 minutes. If the user came back to this tab after 30 minutes the 2 minutes that were reported initially would remain which is a bit random.

Ideally, we would maybe sent for how long a user was actually active. This could be done by calculating the time actively spent on the page in JavaScript and eg by sending a request like ping=10 for "user spent 10 seconds on this page".

I presume different users might expect different behaviour. The current implementation can lead to quite random numbers depending on how a user navigates through tabs.

@tsteur tsteur added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label Jan 18, 2016
@hpvd
Copy link

hpvd commented Jan 18, 2016

we expierience this problem when testing for #9504 too.

Ideally, we would maybe sent for how long a user was actually active. This could be done by calculating the time actively spent on the page in JavaScript and eg by sending a request like ping=10 for "user spent 10 seconds on this page".

hmm do we need to send a time/duration? Couldn't one only use the information that there was no ping or action in the meantime
(determinded on page to decide sending a ping or not

before each ping one can simply check if mouse position in browser window is still the same than before last ping - if so no new ping is send.
#9504 (comment))

within statistics?

@tsteur
Copy link
Member Author

tsteur commented Jan 18, 2016

hmm do we need to send a time/duration?

We might be able to calculate it server side but not really since the interval will be configurable at some point in the tracker. We need to see once someone actually starts working on it.

Re mouse see #9542 (comment)

@tsteur
Copy link
Member Author

tsteur commented Jan 18, 2016

Actually we could use it on top within an iframe maybe to see if window had focus but not sure if we should since it can make it quite slow to listen to it. Idea could be to listen to all mouse movements and scroll events. As soon as it was fired once, set hadFocus = true and remove the event listeners again to not make page slow. However, this would require that someone moves the mouse over an iframe or scrolls in it which eg might not work for Ads within an iframe. Also I'm not sure if we actually get mouse events in an iframe as soon as the mouse is over it when the window is not focussed. This needs to be tested.

@hpvd
Copy link

hpvd commented Jan 18, 2016

We might be able to calculate it server side but not really since the interval will be configurable at some point in the tracker. We need to see once someone actually starts working on it.

maybe it could help to send ping period setting once when loading the page.

@Glisse1
Copy link

Glisse1 commented Jan 20, 2016

very welcomed improvement, hope this ticket will get some attention in the near future.. I was very happy when heartbeat ping was introduced, but I noticed immediately that the accuracy was not that good, for the very reasons presented here by tsteur... but still, "not that accurate" is way better than nothing at all, so for now I am happy with what I can get :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

5 participants