To understand Google Analytics 4 sessions, let’s start with a small throwback to Universal Analytics.
Universal Analytics and Google Analytics 4 differ mainly in how sessions are created, from which a user familiar with either tool can determine what differences exist between them. It is important to note that in GA4, everything is an event, including the start of a session (session_start).
Universal Analytics creates the session at the level of data processing, which is the most important difference. During this process, something known as the session scope is created.
At the time when data arrives (hits are sent) to the Universal Analytics sessions, they do not exist. In Universal Analytics, the data is sorted by user identifier and timeline. After the data is processed, Universal Analytics creates what we call a „session” or “session scope.“
This creation then involves two parameters that can split the session into two or more sessions:
- Campaign source
The session can be divided into two parts over time:
- After 30 minutes of inactivity. Each subsequent hit is then already part of a new session.
- At midnight
- The campaign updates anytime the user arrives at your site via a search engine, referring website, or campaign-tagged URL. Direct traffic, however, never updates or replaces an existing campaign source.
Google Analytics 4 sessions
To understand the session, you just need to understand the values in this cookie, which maintains the user’s session state. We can see the cookie in the picture below.
The most important parts of this cookie are the numbers “1676131808” and “1676131821”.
The first mentioned number, “1676131808” is a timestamp that tells the exact time of the GA4 configuration. (or the first event sent to the GA4). This number is sent with every hit as the sid (session id) parameter in GA4 event requests.
The second number, “1676131821” is a timestamp of the last event sent to the GA4, including automatically collected events like user_engagement. Every time the time range between new and old event timestamps is longer than 30 minutes (default value of session length), a new session id is generated. It means that the first number, “1676131808” is regenerated and a new session starts. Each time the session number is updated to a new value. The _ss (session start) parameter is sent with the first following event, which then generates a “session_start” event in Google Analytics 4.
Note: There is no limit to how long a session can last, and it can be adjusted on the stream level in GA4.
It is important to note that session_id is not a unique identifier, and multiple users may share it if a web application is accessed at the same time. A session in Google Analytics 4 is identified by a pair of session_id and client_id values.
- Session scope in Google Analytics 4 does not exist. Everything is calculated on the frontend of the web.
- Session in GA4 can be determined as a number of pairs of session_id and client_id. Easier way to consider number of session is by counting of session_start events (but be careful when consent mode is turned on)
- In Google Analytics 4 sessions do not split at midnight or when the campaign source is changed.
There is also a parameter called „session_number,” which is also present in the cookie, but it is not important for understanding sessions in GA4. You can also have questions about how it works when consent mode is turned on; think about it next time.