GA4 Cookie Format Change (GS2): What It Means for Tracking

GA4 Cookie Format Change (GS2): What It Means for Tracking: GA4 & analytics article cover from AnalyticsLiv

In short

In 2025 Google switched the GA4 session cookie (_ga_<container-id>) from the GS1 format to GS2, which stores labelled key-value pairs such as session ID, session number and engagement. Sites using GTM or gtag.js need no changes. Only custom code that parses GA4 cookies, for example for the Measurement Protocol, must be tested and updated.

Contents6 sections

Talk to a specialist

Google Analytics 4 (GA4) uses first-party cookies to manage sessions and identify returning users, as part of a more privacy-conscious approach to measurement. In 2025 Google changed the format of the GA4 session cookie from GS1 to GS2. This post explains what each GA4 cookie does, how to read the new value and who needs to act.

The main GA4 cookie is _ga, which stores a Client ID: a unique, randomly generated identifier for each browser. The Client ID lets GA4 tell new and returning visitors apart and follow user journeys over time.

Which cookies does GA4 set?

Google's GA4 cookie list includes two cookies, both with a default lifespan of 2 years:

  1. _ga: used to distinguish users. It stores a unique random number for each browser to identify repeat visits.
The _ga cookie in browser developer tools
_ga cookie
  1. _ga_<container-id>: used to persist session state. It tracks activity within a visit, which GA4 uses for session counts, session duration and engagement.
The _ga_ container cookie in browser developer tools
_ga_<container-id> cookie

You may also see a _gid cookie with a 24-hour lifespan. It belonged to Universal Analytics (analytics.js) and is not in Google's GA4 cookie list, so it only appears if an older analytics.js tag is still on the page.

The _gid cookie in browser developer tools
_gid cookie

The _ga cookie keeps its familiar structure:

Example _ga cookie value
_ga cookie format

GA1.1.1162820436.1749482504

PartMeaning
GA1Format version.
1Domain level. For example, example.com has a level of 1 and sub.example.com a level of 2.
1162820436Random number that, with the timestamp, identifies the browser (the Client ID).
1749482504Timestamp of when the cookie was created, usually the user's first visit.

The _ga_<container-id> session cookie now uses the GS2 format. Instead of values in fixed positions, it uses labelled key-value pairs separated by $:

GS2.1.s1749482503$o1$g1$t1749482510$j53$l0$h1446824558

Example GS2 session cookie value
GS2 session cookie format

Google does not publish definitions for each field. The table below shows how the fields are commonly read, based on observed values:

PartMeaning
GS2Format version 2.
1Domain level.
s1749482503Session ID, set at the start of the session. The same value is sent as ga_session_id in GA4 hits.
o1Session number (1, 2 and so on), sent as ga_session_number.
g1Engaged session flag (0 or 1).
t1749482510Timestamp of the last hit.
j53Join timer.
l0Login (enhanced user) state.
h1446824558Hashed user ID.
Session ID from the cookie shown in the ga_session_id parameter
The session ID (s) is sent in the ga_session_id parameter
Session number from the cookie shown in the ga_session_number parameter
The session number (o) is sent in the ga_session_number parameter

Why did GA4 change the cookie format?

Because GS2 uses key-value pairs, Google can add, remove or update fields later without breaking the structure. The labels also reduce ambiguity: developers and analysts can tell what each field holds without memorising the position of each value.

Not if you use GTM or gtag.js as they are: the tags read and write the cookie for you.

It does matter if you run custom code that parses GA4 cookies directly, for example to read the session ID or session number for the Measurement Protocol or a server-side setup. Code written for the old GS1 positions can return wrong values with GS2, so test it and update the parsing.

Conclusion

The GS2 format is a small change for most sites, but it can quietly break custom integrations that read cookie values. Check any code that parses _ga_<container-id> so your session data stays accurate. If you are not sure whether anything in your setup reads GA4 cookies, a GA4 audit will show it.

Frequently asked questions.

Ask us your own question

Two first-party cookies, both with a default lifespan of 2 years: _ga, which distinguishes users, and _ga_<container-id>, which persists session state.

The newer format of the _ga_<container-id> session cookie. Instead of values in fixed positions, it uses labelled key-value pairs separated by $, such as s for the session ID, o for the session number and g for the engaged-session flag.

Not if you use GTM or gtag.js as they are. Only custom code that parses GA4 cookies directly, for example to send session data through the Measurement Protocol, needs testing and updating.

Need help with GA4?

Talk to the team that sets up, audits and fixes GA4 and Tag Manager for clients.