Analytics cookie · Google Analytics 4

_ga_<container-id> Cookie: What It Is, Who Sets It, and Consent Rules

Last verified 2026-10-16 · Updated 2026-10-17

On this page
  1. What the _ga_<container-id> cookie does
  2. Who sets the _ga_<container-id> cookie
  3. Does the _ga_<container-id> cookie need consent?
  4. How to block the _ga_<container-id> cookie
  5. How long the _ga_<container-id> cookie lasts
  6. Cookies that work with _ga_<container-id>
  7. Scripts and requests of Google Analytics 4
  8. _ga_<container-id> cookie FAQs

What the _ga_<container-id> Cookie Does on Your Site

The _ga_<container-id> cookie is a first-party analytics cookie that Google Analytics 4 sets to keep the session state of a single property. The _ga_<container-id> cookie stores the start time of the current session, the number of sessions, and the time of the last hit. Google describes the _ga_<container-id> cookie as "Used to persist session state". The <container-id> part is the measurement ID of the property without the G- prefix, so the measurement ID G-CSJ3Z71FRB writes a cookie named _ga_CSJ3Z71FRB.

The value of the _ga_<container-id> cookie looks like GS2.1.s1712345678$o3$g1$t1712349999$j55$l0$h0. The table explains each part. Google publishes no value format. Read the meanings in the table as an interpretation that Google has not confirmed.

Part of the valueMeaning
GS2.1The format version of the cookie and a number the Google tag sets from the domain.
s1712345678The start time of the current session as a Unix timestamp in seconds.
o3The session number, here the third session of the browser on the property.
g1Whether the session counts as engaged, with 1 for engaged and 0 for not engaged.
t1712349999The time of the last hit as a Unix timestamp in seconds.
j55, l0, h0Fields that Google documents nowhere, so check them again before you rely on them.
_ga_<container-id> cookie facts
Cookie name_ga_<container-id>
VendorGoogle Analytics 4
CompanyGoogle LLC (Google Ireland Limited for visitors in the EU)
CategoryAnalytics
PartyFirst-party
DomainYour own root domain, for example .example.com
Set byJavaScript, through the Google tag (gtag.js) or Google Tag Manager
Retention2 years (730 days), renewed at every page view
Value exampleGS2.1.s1712345678$o3$g1$t1712349999$j55$l0$h0
HttpOnlyNo
SecureNo
SameSiteNot set by the Google tag, so browsers apply Lax
Cookie Consent categorytracking
Privacy Consent vendor categoryAnalytics (analytics)

Who Sets the _ga_<container-id> Cookie

Google Analytics 4 sets the _ga_<container-id> cookie through the same Google tag (gtag.js) that writes the _ga cookie, added to the page directly or through Google Tag Manager. Each Google Analytics 4 property on the page writes its own cookie, named after its measurement ID. A site that sends data to 2 properties carries 2 _ga_<container-id> cookies next to a single _ga cookie.

The Google tag writes the cookie with JavaScript on your own domain, which makes the cookie a first-party cookie. Google describes the purpose as keeping the session state, so Google Analytics 4 knows whether a page view belongs to a running session or starts a new session.

Read how Google LLC handles the data in the Google Analytics 4 privacy policy, and sign the Google Ads Data Processing Terms, which cover Google Analytics before you collect data from visitors in the EU or the UK. Both documents appear in the sources at the end of this page.

How to Block the _ga_<container-id> Cookie Until Visitors Accept

Block the _ga_<container-id> cookie by holding back the Google tag (gtag.js) until the visitor accepts analytics cookies. TermsFeed Free Cookie Consent and TermsFeed Privacy Consent place Google Analytics 4 in the analytics category. Check whether an exemption applies to your own use of Google Analytics 4 in the consent rules for the _ga_<container-id> cookie.

Block the _ga_<container-id> Cookie With TermsFeed Free Cookie Consent

TermsFeed Free Cookie Consent runs a tagged script only after the visitor accepts its category. Change type="text/javascript" to type="text/plain" and add data-cookie-consent="tracking", the Cookie Consent category for analytics cookies. The tagged the Google tag (gtag.js) looks like this.

<script type="text/plain" data-cookie-consent="tracking" async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script type="text/plain" data-cookie-consent="tracking">
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'TAG_ID');
</script>

Cookie Consent runs the tagged code after the visitor clicks "I agree" or accepts the tracking category in the Preferences Center. The illustration shows the consent banner and the script it releases.

The TermsFeed Free Cookie Consent banner: (1) the visitor clicks "I agree", (2) Cookie Consent runs the script tagged tracking. Illustration of the consent banner.

Cookie Consent is free and needs no account. Build your free consent banner with TermsFeed Free Cookie Consent.

Block the _ga_<container-id> Cookie With TermsFeed Privacy Consent

Add Google Analytics 4 from its template in TermsFeed Privacy Consent, and Privacy Consent loads the Google tag and sends Google Consent Mode v2 for you. Type your measurement ID, which starts with G-, and the template fills the vendor, the Analytics vendor category, and the consent signals.

The template runs the Google tag in advanced consent mode, so Google Analytics 4 sets the _ga cookies only after the visitor accepts the Analytics vendor category. Run Google Analytics 4 without the template, in basic consent mode, where your legal advice asks for no request to Google before consent.

The Google Analytics 4 template asks for the Measurement ID and fills every other field of the vendor. Pick the "Google Analytics 4" card under Analytics, enter the Measurement ID, and click "Add Google Analytics 4". Find the Measurement ID in Google Analytics under Admin › Data streams › your web stream. The illustration shows the template form in the TermsFeed app.

The Google Analytics 4 template in TermsFeed Privacy Consent: (1) pick the card, (2) enter the Measurement ID, (3) click "Add Google Analytics 4". Illustration of the TermsFeed app.

Privacy Consent detects the location of each visitor and records every answer in a consent log. Set up Google Analytics 4 from its template with TermsFeed Privacy Consent.

Block the _ga_<container-id> Cookie With Google Consent Mode v2

Google Consent Mode v2 loads the Google tag before consent and stops the Google Analytics 4 cookies while analytics_storage is denied. Google tags "won't read or write first-party analytics cookies" while analytics_storage is denied, according to the Google consent mode documentation.

Advanced consent mode sends measurements without cookies to Google while consent is denied, and Google uses them for modeling. Basic consent mode loads no Google tag before the visitor answers. Choose basic consent mode to send no request to Google before consent.

Set up the default and the update calls with how to integrate Google Consent Mode v2 with Cookie Consent.

How to Verify That the _ga_<container-id> Cookie Waits for Consent

Verify the setup in a private window. Open Chrome DevTools, select the Application tab, and open Cookies. Click "I decline" on the consent banner and reload the page. The _ga_<container-id> cookie must not appear in the list until you accept analytics cookies.

How Long the _ga_<container-id> Cookie Lasts

The _ga_<container-id> cookie lasts 2 years (730 days), and the lifetime restarts at every page view. Chrome keeps the cookie for 400 days (about 13 months) at most, according to the Chrome team. Safari caps the cookies that JavaScript sets at 7 days of Safari use without an interaction with your site, according to the WebKit team behind Safari.

The session inside the cookie ends long before the cookie expires. A session times out after 30 minutes without activity by default, and the next page view starts a new session in the same cookie, according to Google. Change the session timeout in Google Analytics under Admin, Data streams, Configure tag settings, and Adjust session timeout.

The Override cookie settings in the Google Analytics interface and the cookie_expires setting of the Google tag change the lifetime of the Google Analytics cookies. The _ga and _ga_<container-id> cookies therefore keep the same lifetime.

Scripts and Requests of Google Analytics 4 That Come With the _ga_<container-id> Cookie

The catalog lists 6 scripts, pixels, and data endpoints of Google Analytics 4, which a cookie scanner or the Network tab of Chrome DevTools shows next to the _ga_<container-id> cookie. Block the main script, and the requests in the table stop with the main script.

TypeResourceHostWhat it does
ScriptGoogle tag for Google Analytics 4 (gtag.js)www.googletagmanager.comThe Google tag loads Google Analytics 4 on the page and writes the _ga and _ga_<container-id> cookies.
Data endpointGoogle Analytics 4 collection endpointregion1.google-analytics.com
www.google-analytics.com
analytics.google.com
The collection endpoint receives every page view and event, with the client ID from the _ga cookie in the cid parameter.
Data endpointGoogle signals collection endpointstats.g.doubleclick.netGoogle Analytics 4 sends measurements to stats.g.doubleclick.net while Google signals is on, which links visits to signed-in Google accounts.
PixelGoogle Analytics audiences pixelwww.google.com
www.google.fr
www.google.de
The ga-audiences pixel adds the visitor to Google Ads remarketing audiences built in Google Analytics, and the TermsFeed website auditor found the pixel firing after consent on scanned sites.
ScriptUniversal Analytics library (analytics.js)www.google-analytics.comThe analytics.js library ran Universal Analytics and wrote the _ga, _gid, and _gat cookies.
Data endpointUniversal Analytics collection endpointwww.google-analytics.comThe Universal Analytics endpoint received hits from analytics.js until 1 July 2023.

_ga_<container-id> Cookie FAQs

Why does my site have 2 _ga_ cookies?

Your site sends data to 2 Google Analytics 4 properties, and each property writes its own _ga_<container-id> cookie. Compare the part after _ga_ with the measurement IDs in Google Analytics, under Admin and Data streams, to find both properties. Remove the tag of the property you no longer use, and the extra cookie stops at the next visit.

Is the _ga_ cookie necessary?

No, the _ga_<container-id> cookie is not a strictly necessary cookie. Firstly, the cookie serves the analytics reports of your site, not a service the visitor asks for. Secondly, your site works the same for a visitor who refuses analytics cookies. Thirdly, Google tags read and write no first-party analytics cookies while analytics_storage is denied in Google Consent Mode v2, according to Google.

How do I rename the _ga_ cookie?

Add a cookie_prefix value to the configuration of the Google tag, and the Google tag adds the prefix to the names of the Google Analytics cookies. A cookie scanner then reports the cookies under the new names. Update your Cookies Policy with the new names, so the list matches what visitors find in the browser.

Sources for the _ga_<container-id> Cookie

The facts on this page come from the documentation Google publishes, checked on 2026-10-16. The catalog lists every source so you check each fact yourself.