Analytics cookie · Google Analytics 4

_ga Cookie: What It Is, Who Sets It, and Consent Rules

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

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

What the _ga Cookie Does on Your Site

The _ga cookie is a first-party analytics cookie that Google Analytics 4 sets to tell one visitor apart from another. The _ga cookie stores a random client ID and the time of the first visit. Google Analytics 4 sends the client ID with every page view and event, which lets your reports count users instead of page loads. Google describes the _ga cookie as "Used to distinguish users" in the Google Analytics help article "Google Analytics cookie usage on websites".

The _ga cookie works with the _ga_<container-id> cookie. The _ga cookie identifies the browser for every Google Analytics 4 property on the site, and the _ga_<container-id> cookie keeps the session state of a single property.

The value of the _ga cookie looks like GA1.1.1234567890.1712345678. The table explains each part.

Part of the valueMeaning
GA1The format version of the cookie.
1A number the Google tag sets from the domain the cookie belongs to.
1234567890A random number.
1712345678The time of the first visit as a Unix timestamp in seconds, which is 5 April 2024 in the example.
1234567890.1712346The client ID that Google Analytics 4 counts as 1 user.
_ga cookie facts
Cookie name_ga
VendorGoogle Analytics 4
CompanyGoogle LLC (Google Ireland Limited for visitors in the EU)
CategoryAnalytics
PartyFirst-party
DomainYour own root domain, for example .example.com. Google tags set cookies "on the highest level of domain possible", according to the Google tag documentation.
Set byJavaScript, through the Google tag (gtag.js) or Google Tag Manager
Retention2 years (730 days), renewed at every page view
Value exampleGA1.1.1234567890.1712345678
HttpOnlyNo
SecureNo, unless you add Secure with the cookie_flags setting of the Google tag
SameSiteNot set by the Google tag, so browsers apply Lax. Add SameSite=None;Secure with the cookie_flags setting for a site inside an iframe.
Cookie Consent categorytracking
Privacy Consent vendor categoryAnalytics (analytics)

Who Sets the _ga Cookie

Google Analytics 4 sets the _ga cookie through the Google tag (gtag.js) that you add to your site directly or through Google Tag Manager. Plugins and apps add the same Google tag, for example Site Kit by Google on WordPress and the Google and YouTube app on Shopify. A site then sets the _ga cookie without any code edit.

The Google tag writes the _ga cookie with JavaScript in the browser, so the _ga cookie belongs to your domain and counts as a first-party cookie. Google still receives the client ID with every measurement request to google-analytics.com.

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 Cookie Until Visitors Accept

Block the _ga 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 cookie.

Google Analytics 4 writes no _ga cookie while the Google tag waits as a tagged script, so a visitor who declines sends no request to Google Analytics.

Block the _ga 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 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 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 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 cookie must not appear in the list until you accept analytics cookies.

How Long the _ga Cookie Lasts

The _ga 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.

Change the lifetime in Google Analytics under Admin, Data streams, Configure tag settings, and Override cookie settings, which accepts a value from immediately to 25 months, according to Google. A cookie_expires value in the Google tag or in Google Tag Manager takes precedence over the setting in the Google Analytics interface.

Expect a shorter lifetime than 2 years in practice. Scans of 2 sites by the TermsFeed website auditor on 9 October 2026 found the _ga cookie with a 400-day expiry in Chrome on both sites. Chrome applies that 400-day limit to every cookie.

Scripts and Requests of Google Analytics 4 That Come With the _ga 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 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.

Changes to the _ga Cookie

The catalog records 2 dated changes that affect the _ga cookie. The newest change comes first.

DateChange
1 July 2023Universal Analytics stopped processing data for standard properties. Google Analytics 4 kept the _ga cookie with the same name, so sites that moved to Google Analytics 4 kept the client IDs of returning visitors.
August 2022Chrome 104 capped the lifetime of every new cookie at 400 days (about 13 months), which shortens the 2-year _ga cookie in Chrome.

_ga Cookie FAQs

Is _ga a necessary cookie?

No, the _ga cookie is not a strictly necessary cookie. Firstly, your site works the same for a visitor who refuses the _ga cookie. Secondly, Google Analytics 4 uses the _ga cookie to measure visitors, a purpose the ePrivacy Directive exemption does not cover. Thirdly, Google itself stops the _ga cookie through Google Consent Mode v2 until the visitor grants analytics_storage.

Does the _ga cookie contain personal data?

Yes, the _ga cookie holds personal data under the GDPR. Firstly, the client ID in the _ga cookie is unique to a single browser. Secondly, Recital 30 of the GDPR names cookie identifiers among the online identifiers that make a person identifiable. Thirdly, Google Analytics 4 links every page view and event of the browser to the same client ID.

What is the difference between the _ga and _ga_ cookies?

The _ga cookie identifies the browser, and the _ga_<container-id> cookie stores the session state of a single Google Analytics 4 property. The <container-id> part is the measurement ID of the property without the G- prefix, so a site with 2 properties sets 1 _ga cookie and 2 _ga_<container-id> cookies.

What is the difference between _ga and _gid?

The _ga cookie identifies a browser for 2 years, and the _gid cookie identified a browser for 24 hours in Universal Analytics. Google Analytics 4 sets no _gid cookie, so a _gid cookie on your site today comes from an old Universal Analytics tag. Remove the old tag, because Universal Analytics stopped processing data on 1 July 2023.

How do I delete the _ga cookie?

Delete the _ga cookie in Chrome DevTools: open the Application tab, open Cookies, select your domain, and delete the _ga row. The Google tag writes a new _ga cookie with a new client ID at the next page view, so Google Analytics 4 counts the same person as a new user.

Sources for the _ga 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.