-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adds Time on Page metric to Top Pages report #1007
Conversation
Needs more testing & potentially cleanup
test/plausible_web/controllers/api/stats_controller/pages_test.exs
Outdated
Show resolved
Hide resolved
This was due to Clickhouse setup not inserting the sessions with the exact same timestamp consistently and making the test inconsistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
Currently I've just set up the naive approach
That's fine. We'll do some experiments with sendBeacon
in the future but I think this is good enough for now.
This query isn't exactly super fast, but I'm not sure if that's just my amount of data vs the speed of my dev environment
I did some testing. With sampling enabled for our biggest client, it's taking about 4-5s on our production environment. I think that's acceptable for a detail view which is supposed to calculate more stuff. Some sort of sendBeacon
approach would certainly be much faster because then we wouldn't need to calculate neighbours or anything like that, it would be stored in a table like any other metric.
In terms of performance, I would like to get the bounce_rate and time_on_page queries running in parallel so the user can get their page rendered quicker.
As for improving performance with beacons, we may have some different ideas there - my intention was that beacons would only add a |
I noticed that filters that act on the For example when you click on a source from |
Ah yeah good call - I pretty much fully forgot that sessions could get filtered on haha |
@ukutaht The concerns on the session-based filtering are all sorted now - I did also now put in a fix where a page filter was completely breaking the calculations, since it was trying to only calculate neighbors with same-page transitions (whoops). One other big thing I just added though, is some better timeout and error handling with the parallelized tasks, in the old method if either one failed or timed out - the entire request would exit, now, if one errors or times out (more likely to be the time on page, on slower hardware/larger data sets), it gracefully handles it and just returns no data for that column instead of no data for any of the columns. I'm not entirely certain that my Elixir here is great though, so lmk what you think there. I have the timeout set at 15 seconds which I think is a reasonable timeout where any data possible should be sent and the rest aborted, but if you want to increase that, it could be. |
Everything looks good @Vigasaurus! |
I think we're mostly on the same page about how to design this thing. The way you've described it sounds good. We already have an in-memory record of each session along with the latest page the person viewed in the Adding a A potential solution could also just update the latest pageview record with a |
Yeah I think those are all really good ways to go about it. I honestly think that last method could work pretty well for maybe every type of pageview or exit - such that the closest previous event gets the duration set on ingest of its forward neighbor. Only potential concern I have there is how we'd control which query needs to happen - this version or the manual neighbor version from this PR; maybe something like the grandfathered plans to pick a date when the new query is usable and only use it if the date range ends before it. |
Thanks @Vigasaurus for this! Just testing it on staging. When I drill down and filter by a page, the top graph doesn't show time on page. Would be nice to display it next to the bounce rate there on top. |
Good idea - will do 👍 |
Changes
Title.
Couple of things here to discuss though -
exit
, such that it won't count as a pageview, and will always end a session. (There is another thing to discuss here on if you think using the visibility change method for ending sessions is appropriate - as this can have false positives with users swapping tabs) lmk what you think.Tests
Changelog
Documentation
Screenshots