Skip to main content

🔒 GA4 | tutorials

How to sessionize your GA4 event data in BigQuery (part 2: custom session definitions)

How to customize session definitions for GA4 event data in BigQuery by basing them on user actions instead of time passed. It covers various custom definitions including specific page view events, and post-purchase events, and provides instructions for implementing them using SQL logic.

This tutorial is a follow up of part 1: default 30-minute session timeout definition. In part 2 you will learn to sessionize your GA4 event data using custom session definitions. Instead of looking at a specific amount of time that has passed, we will focus on the actions of the user.

Rethink the concept of a session

When we talk about sessions in web analytics, most of you will think of the default session definitions Google introduced a long time ago. GA4's session timeout of 30 minutes is basically the same as it was for years and years in Universal Analytics (GA3).

But why should we rely on one - arbitrary - definition if we can rethink and construct our own concept of a session? Instead of looking at a specific amount of time that has passed, we could focus on the actions of the user (or the time frame of intent).

Defined by user action

Imagine a user visits an online clothing store and begins browsing for a new outfit. They start by viewing the home page and then click on a link to view the store's selection of dresses. From there, they select a particular dress and view its details, such as the available sizes and colours. The user then adds the dress to their shopping cart and continues browsing the site, looking at other items and adding them to their cart as well.

In this scenario, the user's interactions with the website – starting from when they first visit the home page and ending when they add items to their shopping cart – would constitute a single session. The length of time that has passed is not relevant in this case; the session is defined by the user's actions on the website.

Possible definitions

Possible custom session definitions we will explore in this tutorial:

  1. Set the session timeout to 5 minutes, 24 hours or 7 days
  2. Every page_view event on a specific page is the start of a new session
  3. Every event after a purchase event is the start of a new session

I realize all custom session concept have their flaws, just like the default 30-minute timeout definition has. Which definition works for you and suits your use case is also very subjective.

Rather than presenting any out of the box solution, I will show you how to use SQL logic to experiment with custom session definitions, so you can unleash your own creativity on the GA4 export data.