GA4 Session Handling and Essential Mode for Data Consistency
In the dynamic field of digital analytics, maintaining data consistency and user privacy is crucial. Google Analytics 4 (GA4) introduced a robust set of session-related parameters that enable detailed tracking and analysis of user interactions. Designed for app tracking at first (also formerly known as Firebase Analytics) it was later migrated into a full blown digital analytics swiss knife, covering website analytics same as app data streams.
This documentation article explores how JENTIS, your server-side data capturing and tag management solution, leverages Essential Mode to handle GA4 session parameters with precision, ensuring data consistency and compliance with privacy regulations.
Technical Foundations - GA4 Session Parameters
GA4 utilizes several session-related parameters to track user interactions accurately. These parameters are originally stored within app storage and are persisted on a user's device via cookies and local storage when GA4 is run in a website environment. Further, in the JENTIS context, all those are persisted server-side when GA4 is configured to run on the server. Thus, they are crucial for consistent reports and must be evaluated in light of each individual configuration and runtime.
These parameters include:
Client ID (
cid
): A unique identifier for each “user” in accordance with reports and metrics. One client id (user) can have many sessions (1:n relationship). If a client-id changes (ie. when anonymized or pseudonymized) all session parameters must follow suit. So data remains consistent with all reports.Event Counter (
_s
): A sequential counter for events.Session ID (
sid
): A unique identifier for each session.Session Count (
sct
): The number of sessions a user has initiated.Engaged Session (
seg
): Indicates whether the session is engaged (ie. the user navigated further into the site or remained on page and time elapsed to a certain threshold).User ID (
_uid
): A unique identifier for logged-in users that you can use optionally, if configured it will have same implications as client-id (see above).First Visit (
_fv
): Indicates the user's first visit (new user).Enhanced Client ID (
ecid
): An enhanced version of the client ID, which is used in certain edge cases but generally must not be used for most cases. It is a hidden parameter under the hood of GA4 protocol and is not officially documented.Session Start (
_ss
): Indicates the start of a session.Pageview Count and First Pageview Indication: Essential for determining the correct session start.
Essential Mode in JENTIS
Essential Mode in JENTIS is a framework designed to handle data capturing and tag management in scenarios where user consent is required. When Essential Mode is activated, you can configure JENTIS to only collect essential data, maintaining compliance with privacy regulations such as GDPR. Find out more: Essential Mode
Decision Tree: Handling GA4 Session Parameters in Essential Mode
The following decisions in your configuration determine how to approach each scenario during configuration to get the best results for data intelligence.
Do you want to run GA4 on the server-side?
JENTIS offers both client-side and server-side operation modes. In client-side operations, Google Tag (GTAG) will handle all session parameters for you, but Essential Mode is unavailable in this configuration (so data of denied consent will be missed entirely).
If you decide to configure GA4 to run on the server side, continue reading this article.
Do you wish to configure Essential Mode (to get the full picture of your website traffic while maintaining principles of least privileges and data minimization, so it is secure and privacy-enhancing)?
With Essential Mode, you’ll need to decide which parameters will be anonymized when consent is not granted. When using the JENTIS Platform, GA4 is implemented with your JENTIS account and server (container).
If you choose not to activate Essential Mode, JENTIS will configure your GA4 server-side tags as a default, ensuring consistent data (as only consented users data is captured).
If you decide to activate Essential Mode, continue reading this article.
Must Client-ID be obfuscated for your Essential Mode configuration?
In the scenario of GA4 server-side tags and active Essential Mode configuration, it is crucial to apply the correct session handling properties.
If client-id is neither anonymized nor pseudonymized, then it will be the same value in regular (consent mode) and with the fallback (Essential Mode) configuration, so data will remain consistent in that case (which means no special todo applies here).
If you wish to anonymize or pseudonymize the client ID with Essential Mode configuration, please read on in the corresponding sections below.
When Essential Mode is activated, it is crucial to set GA4 session parameters with great care to ensure data consistency. While the most important foundation remains the Client ID, which is from our experience often configured with either anonymization or pseudonymization functions applied to improve data privacy, as the data can further not be traced back.
Anonymized Client ID

In this case, the Client ID value will be randomly generated for each individual event tracked with GA4. Thus, data can only be used to estimate traffic volume by event count but not by session or user count. In this case, you might want to configure a different measurement ID (new GA4 property) so this data does not pollute your general reports (where users consent and consistent Client ID values can be used).
Further, while each event will have a different (and thus by design and definition be inconsistent) Client ID value, the session-related parameters will remain consistent. As JENTIS still correctly identifies the user and the Session ID, Session Counter, etc. will be consistent if they are not overridden with static or custom values.
As this sounds possibly confusing let’s unwrap this data consistency and configuration consistency topic in detail.
JENTIS as your tag and data routing management is consistent in handling the data, but the recipients (tools) in your configuration must only receive data based on terms. Which means in case of denied consent that the recipient tool will only receive essential data. And here the configuration in regards to single parameters like Client-ID and session information must be consistently configured (to always apply anonymization or to not apply anonymization). Application of anonymization on some parts (Client ID) but not on other (session data) will create a bad outcome in the reporting later.
Make sure to apply there meaningful configurations that match your configuration with regards to Client ID and measurement ID.
Pseudonymized Client ID
While implementing pseudonymization (such as generating a random Client ID per user) can be complex, JENTIS ensures consistency by maintaining the same pseudonymized Client ID for each individual visitor (JENTIS User). This means that as long as a user maintains their consent preference (e.g., declines and doesn’t change it), the data remains stable and reliable. In cases where a user changes their mind or consents shortly after the first event is tracked, it's important to be mindful of potential session-related challenges.
If the consent decision for website visitors is consistent between your website and GA4 server-side Essential Mode configuration, you must not apply any special session handling configuration.
If the situation is different and consent per user changes often (as described above), you must make sure to set all session-related parameters with GA4 with consent-sensitive configurations.
One way to achieve this is by creating a copy of each variable (for each User session configuration option), e.g., " GA4—Event-Counter—Essential Mode” (with the appropriate suffix to quickly identify it). In all variables, you must make sure to adjust the server-side storage to read and write all values in a different key than the original.
Let’s examine one such configuration as an example: “GA4 - Pageview-Counter” (variable)
async function ga4_pageview_counter() {
let counter = await this.storage.read("page_view_counter");
let isSessionExisting = await this.storage.read("session_handler");
this.storage.write("session_handler", "1", Date.now() + 1800000);
// If the session expired, we have to start from the beginning with the counter
if (typeof isSessionExisting !== "undefined" && isSessionExisting !== null && isSessionExisting === false) {
counter = 0;
}
// Raise the counter per event
counter += 1;
this.storage.write("page_view_counter", counter, Date.now() + 94608000000);
// Never return anything here, because it is directly in the stream placed!
return "";
}
In this original code, you’d need to change the storage.read
and storage.write
to different keys (so consent- and non-consent-users have different values as the client-id is different due to pseudonymization).
The page_view_counter
can be renamed to page_view_counter_em
, the session_handler
to session_handler_em
etc. Be consistent in this renaming and make sure that all variables and cross references are consistent (ie. the session_handler_em
must also be used in other variables).
These new Essential Mode-specific variables must now be used with ALL your GA4 server-side tags. Also, make sure to use them when a new tag is created in the future. The Multi-Tag Edit will help you apply all changes at once!
Conclusion
Handling GA4 session parameters precisely is essential for maintaining data consistency and compliance with privacy regulations. JENTIS’ Essential Mode provides a robust framework for managing these parameters, ensuring that data collection remains accurate and reliable, even when user consent is denied and you wish to further anonymize data with pseudonymized Client IDs. By leveraging server-side data capturing and tag management, JENTIS enables organizations to gain valuable insights while respecting user privacy.