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

Monthly time on page number is incorrect #4429

Closed
2 tasks done
soerenreinert opened this issue Aug 9, 2024 · 7 comments
Closed
2 tasks done

Monthly time on page number is incorrect #4429

soerenreinert opened this issue Aug 9, 2024 · 7 comments

Comments

@soerenreinert
Copy link

Past Issues Searched

  • I have searched open and closed issues to make sure that the bug has not yet been reported

Issue is a Bug Report

  • This is a bug report and not a feature request, nor asking for self-hosted support

Using official Plausible Cloud hosting or self-hosting?

Plausible Cloud from plausible.io

Describe the bug

We have a page that has time on page values for only 3 days in July 2024 (44s, 1m41s, and 2m11s). However, for the monthly view of July 2024 the time on page in the dashboard shows 6m40s. Other pages have the same issue.

Expected behavior

The average time on page for July 2024 should be between 1-2mins, and can't be 6m40s.

Screenshots

For example July 2:
Screenshot 2024-08-09 194003

Monthly view July 2024:
Screenshot 2024-08-09 194015

Environment

- OS: Windows
- Browser: Chrome
- Browser Version: 127.0.6533.100
@pmareke
Copy link

pmareke commented Aug 25, 2024

Hi everyone, I would like to give a hand!

I'm taking a look at the code and I can't run the project on my machine, is there any docs with the instructions?

Thanks!

@ruslandoga
Copy link
Contributor

👋 @pmareke

We have https://github.com/plausible/analytics/blob/master/CONTRIBUTING.md

@pmareke
Copy link

pmareke commented Aug 26, 2024

@pmareke
Copy link

pmareke commented Aug 26, 2024

Hi @soerenreinert after taking a look to the code, it looks like the Time on Page is not the average but the sum of all the time the users spent in a given page.

It makes sense then that you have 44 seconds in your page for one day and 6m40s in a month.

If some of the maintainers can confirm my hypothesis would be great!

@ruslandoga
Copy link
Contributor

ruslandoga commented Aug 26, 2024

Right now "Time on Page" is neither an average nor a sum.

It's something like sum(duration(page)) / count(unique(page, next_page, session))

SELECT 
  pathname,
  sum(duration)/countIf(transition) -- <- time_on_page
FROM (
  SELECT
    pathname,
    next_pathname != pathname AS transition,
    sum(next_timestamp - timestamp) AS duration
  FROM (
    SELECT
      leadInFrame(timestamp) OVER event_horizon AS next_timestamp,
      leadInFrame(pathname) OVER event_horizon AS next_pathname,
      timestamp,
      pathname,
      session_id
    FROM events_v2 SAMPLE 20000000
    WHERE -- {...site and date range filter...}
    WINDOW event_horizon AS (
      PARTITION BY session_id
      ORDER BY timestamp
      ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING
    )
  )
  WHERE next_timestamp != 0 AND -- {...some page filter...}
  GROUP BY pathname, next_pathname, session_id
)
GROUP BY pathname

There are plans to improve it.

@RobertJoonas
Copy link
Contributor

Thanks for reporting this @soerenreinert! And thanks @pmareke for your investigation!

There are currently some known issues around the time_on_page metric, which we're planning to fix along with improving the tracking of the metric and making it more accurate in general.

@soerenreinert, I'll be happy to take a closer look at this with specific data if you could please reach out to us at [email protected] and let us know the name of your site in Plausible.

@metmarkosaric
Copy link
Contributor

I'll close this thread for now as it currently works as expected. the time on page issue itself has its own thread where we'll track and post the progress: #2161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants