Solved

Average Time on Page Common Query: Pageviews before Session Ends

  • 12 June 2023
  • 1 reply
  • 48 views

Badge

Hello! I was reading through the common queries to get some inspiration to calculate the average time on page for certain pageviews. 

 

It seems as though this calculation doesn’t take pageviews that occur before bounces into account. Is this correct? I.e. when calculating the average, we’ll only take into account pageviews that are followed by other pageviews. Just want to make sure that I understand the query correctly. Here is the query:

 

 

Thank you!

icon

Best answer by Ariana-Heap 16 June 2023, 18:19

View original

1 reply

Userlevel 1
Badge

Hi @moisternw! Thanks for submitting your question. I’m glad to see you’re exploring our Heap Connect common queries!

Your interpretation of the “Average Time on Page” query is correct. It’s using a subsequent pageview event to signal the end of the current pageview. This means that all pageviews except for the last pageview of a session would be included in this query.

There isn’t an easy way to calculate time on the last pageview of a session because it's not always feasible to determine when a user actually abandoned the session. Heap doesn't track an "end session" event and this is because a session can end a few different ways: a user closes the tab, quits their browser, navigates away in the same tab, or just leaves the tab open but doesn't view a new page within the 30-minute timeout. 

One alternative would be to calculate the difference in time between the last pageview of the session and the last event Heap captured of that session using the all_events view. A couple of items to keep in mind with this approach:

  1. The all_events view in Heap Connect only includes synced event definitions, so there may be raw events with later timestamps that aren’t included in this view.
  2. If the last pageview of the session is also the last synced event (of any kind) of the session, then the time spent on the page will be 0. It would be best to filter the results for only pageviews where the time spent on the page is greater than 0.

I hope this helps! Please don’t hesitate to reach out if you have any more questions. 

Reply