GA4 Cookie Format Update: From GS1 to GS2 Explained

Reading Time: 6 minutes
GA4 update - GS1 to GS2

Google Analytics 4 (GA4) has quietly rolled out a significant update to its session cookie structure, upgrading from the legacy GS1 format to the new GS2 format. This change affects the cookies prefixed with _ga_*, which are used by GA4 to track session-level data. While the update is largely invisible to end users and doesn’t impact most standard tracking implementations, it introduces a more modern and robust method for encoding session information. 

For developers, data engineers, and analysts who rely on directly parsing GA4 cookies – for example, for debugging, building custom attribution models, or syncing analytics with backend systems – this change is particularly important. The underlying structure and encoding of the session cookies have changed, meaning that old parsing logic built around the GS1 format may now break or return inaccurate data when applied to GS2-formatted cookies.

Key Points of the GS1 → GS2 Upgrade:

Encoding Structure: The GS2 format introduces a new, more compact and efficient encoding of session identifiers and timestamps, likely designed to improve performance and resilience.

Backward Compatibility: Existing cookies set in the GS1 format may still persist for a time, but new visitors or users with refreshed sessions will begin receiving cookies in the GS2 format.

Cookie Names Unchanged: The change is entirely internal to the structure of the _ga_* cookies – the names and purpose of the cookies remain consistent.

Impact on Custom Parsing: Any tools or scripts that directly read values from _ga_* cookies (such as for extracting Client ID, Session ID, or timestamps) must be reviewed and updated to handle the GS2 structure correctly.

No Action Needed for Most Users: Websites using GA4 through the official gtag.js or Google Tag Manager (GTM) setup don’t need to take action, as GA4 handles the new format internally.

Old vs. New Format

Old Format

The original Google Analytics cookie format is structured in a clear, dot-separated manner.

GS1.1.1746825440.14.0.17468254406.0.0.295082955

GS1 Format Breakdown

New Format

Google Analytics now uses a more versatile cookie format that includes values with specific prefixes.

Screenshot

Characteristics-

  • Begin with GS2
  • Used $ as separators
  • Each value has prefix
  • No direct client ID

Segments include:

s – Session ID
o – Session Number
g – Session Engaged
t – Last Hit Timestamp
j – Join Timer
l – Logged-In State
h – Hashed User ID

Why Google changed the cookie format from GS1 to GS2 in GA4

1. Improved Extensibility
The GS2 format uses key-value pairs, which makes it much easier for Google to add, remove, or modify fields in the future without breaking existing implementations.

  • In GS1, every piece of data had a fixed position in the string (e.g., the third value was always the session count).
  • In GS2, each piece of data is labeled, so even if new keys are added or old ones removed, it won’t confuse parsers.

2. Self-Documenting Structure
The use of explicit field names (e.g., h=1746825440) makes the cookie much easier to read, interpret, and debug. In this example, the prefix h stands for a hashed user ID, which uniquely identifies the user in an anonymized way. By labeling values with clear prefixes, GA4 reduces ambiguity and allows developers and analysts to understand the purpose of each field without needing to rely on documentation or memorize the position of each value.

3. Version Control
Both GS1 and GS2 start with a format identifier (GS1, GS2) and a version number (e.g., GS2.1), but GS2 improves how versioning is handled.

  • Google can now maintain multiple cookie versions in parallel, each with its own structure.
  • This supports backward compatibility and allows smoother transitions between format updates.

4. Data Optimization
GS2 is more space-efficient in many cases because:

  • It omits unused or default fields.
  • Uses shorter, more compact encoding when possible.

For example, GS1 included placeholder zeros even when fields were unused. GS2 avoids that redundancy.

5. Handles Errors Better
Key-value formats are more resilient to parsing errors than position-based formats:

  • If one field is missing or malformed in GS2, others can still be read.
  • In GS1, misplacing a single value could throw off the entire interpretation.

6. Modern Format
The GS2 format reflects modern web development practices:

  • Key-value pairs are more in line with common data formats like JSON, query strings, or HTTP headers.
  • Makes it easier to integrate GA4 with other tools or libraries.

Who’s Affected by the GA4 Cookie Format Change?

While the transition from the GS1 to GS2 cookie format in Google Analytics 4 (GA4) is seamless for most users, some developers and analysts need to take action – especially those working with cookies at a technical level. Here’s who should pay attention:

You’re Affected If:

  • You Directly Parse GA4 Cookies in Your Code
  • You Use Measurement Protocol with Cookie-Derived Data
  • You Have Custom Integrations (e.g., CRMs, Analytics Layers, Server-Side Tracking)

You’re Not Affected If:

  • You’re Using Standard GA4 Tags (gtag.js or Google Tag Manager)

Why GS2 Matters for Parsing

The shift from GS1 to GS2 changes the cookie structure – using key-value pairs instead of fixed positions. If your code still parses cookies using GS1’s index-based logic, it won’t work correctly with GS2. This can break custom integrations and lead to inaccurate data unless you update your parsing method to handle the new format.

Steps to Take After the GA4 Cookie Format Change

1. Audit Your Setup
Review all parts of your stack where GA cookies (like _ga or _ga_*) are being read or parsed manually.

  • Check custom scripts, tagging setups, middleware, or any backend processes.
  • Identify whether these rely on the old GS1 format.
  • Update any logic that assumes fixed positions to support key-value parsing used in GS2.

2. Validate Measurement Protocol (MP) Payloads
If you’re sending events to GA4 using the Measurement Protocol:

  • Make sure fields like client_id (cid) and session_id (sid) are being correctly extracted and populated.
  • Confirm that the values match what GA4 expects – invalid or missing IDs could cause data loss or misattribution.

3. Check for Tracking Gaps
Look for inconsistencies or missing data in your GA4 reports, BigQuery exports, or any downstream systems that consume GA4 data.

  • A sudden drop in session or user counts could indicate parsing issues.
  • Compare current data trends against historical baselines to detect anomalies.

4. Inspect Logs for Errors
If you’re using server-side Google Tag Manager (ssGTM), custom APIs, or middleware:

  • Review logs for warnings or failures related to cookie parsing.

Conclusion

The shift to the GS2 cookie format is a clear signal that Google is future-proofing its analytics infrastructure – but it’s also a wake-up call for everyone relying on legacy methods of tracking. The era of parsing cookies for critical IDs is coming to an end.

This change isn’t just about one cookie – it’s about how we adapt our data strategies to be more resilient, privacy-conscious, and API-first. Whether you’re building in-house analytics workflows or relying on third-party tools like EasyInsights, it’s time to audit, modernize, and future-proof your stack.

Ignoring the update risks silent data loss and broken attribution. Embracing it opens the door to smarter, more stable tracking built for the future of digital analytics.

To Know more Book a demo today!