Solved

Is it possible to create an event when a session ends ?

  • 18 January 2023
  • 1 reply
  • 41 views

Userlevel 1
Badge

Hi,

I was trying to create a graph to see the average time spent on a page.

First I used the “Average time between events” graph with the pageview as first event and a pageview of any other page as second event.

The probleme is that when a session ends between those two events, the value for the graph is calculated with the next user session pageview.

My questions are : 

  • Is it possible to create an event for the end of a session ?
  • Is there a way to filter results that exceed a certain amount of time ?
  • Is it possible to create an event property that says if the event is the last in the page ?

Thank you for your answers,

Gauthier

icon

Best answer by Brian W 20 January 2023, 15:37

View original

1 reply

Userlevel 1
Badge +1

Hi Gauthier!

These are great questions. Let me try to address them in order:

  • Is it possible to create an event for the end of a session? This is something analytics platforms tend to have a difficult time with. The reason is that there’s no explicit single action a user takes that ends a session. They could close the window or tab, they could leave the tab backgrounded, or they could log out/navigate to a section of your site where Heap isn’t loaded. In Heap, sessions end after 30 minutes of inactivity (on web), which leads to the cookie we set to track the session expiring. However, this often happens while the user’s browser is closed after they exited your site, so Heap isn’t loaded to track the specific time that cookie expired. We can only know a session ended when the user completes their next pageview on your site and a new session cookie is generated, which could be days or months later. This makes a ‘session end’ event very difficult to accurately track.
  • Is there a way to filter results that exceed a certain amount of time? You can restrict the ‘conversion window’ of your Average Time Between graph to an extent, but not in a way that I believe helps too much with your issue. By setting the date granularity of your report to ‘grouped by hour’, this also affects how much time your users have to complete both events and be included in the analysis results. While they’d still have a whole hour to complete both pageviews, this may eliminate a good percentage of the cross-session results.
  • Is it possible to create an event property that says if the event is the last in the page? This isn’t something heap offers out of the box, but you may be able to implement your own event or event property based on the circumstances of the page/pages you’re measuring. How do people leave the page to move to another one? Usually, this will involve users clicking on links that take them to other parts of your site. If this is the main way users navigate away from the pages you care about, you could create an event that captures all link clicks on that page (using a ‘path’ filter in the event definition). Then you could use that as the second event in your ‘average time between’ graph to measure the difference in time between the initial pageview and those link clicks which would result in leaving the page. This is probably the best option we have in the Heap UI for now.

The one other option Heap provides that offers better solutions here is Heap Connect. Heap Connect is a premium feature that allows you to sync your raw Heap data directly to your data warehouse and query it with raw SQL. This provides a far greater range of query options and possibilities. We have some common query boilerplates, including options on how to calculate average time on page and average time on site. For more pricing info on Heap connect and how to get it included in your contract, you can reach out to your account manager or the sales team at sales@getheap.io.

 

Hope this helps!

Reply