The _ga cookie explained: what it stores and lasts
Published November 10, 2026
The _ga cookie is the first-party cookie Google Analytics 4 uses to tell users apart. Here is what it does, how long it lasts, what you can change and what happens without consent.
The _ga cookie is a first-party cookie set by Google Analytics 4 to distinguish users. According to Google's cookie table, it is described as "used to distinguish users" and expires after 2 years by default. A companion cookie, _ga_<container-id>, persists session state and has the same default lifespan.
What does the _ga cookie do?
Google Analytics needs a way to recognize that two page views come from the same browser. The _ga cookie stores a random identifier for that purpose. Each time the same browser returns, the identifier is read again, so GA4 can count the visitor as returning rather than new, and can stitch visits together over time.
Google states that the GA4 tags use first-party cookies to tell apart unique users and unique sessions, and that these libraries do not require you to set cookies to send data to Google Analytics, per the same support page. In other words, the cookie is the default way Google Analytics remembers a browser, not a technical requirement of sending a hit.
What is documented: the name, the purpose and the default expiry. What this glossary entry does not claim: the exact internal format of the value, because Google's public pages do not spell it out.
How long does it last in practice?
On paper, 2 years. In practice, browsers can cut that short. Google notes that browsers enforce limits on the lifespan of first-party cookies when a user does not make a return visit, with a maximum of 400 days for Chrome and 7 days for Safari, as written in the GA4 cookie documentation. A visitor who comes back after eight days on Safari may therefore show up as a new user.
For you, this means returning-visitor numbers in GA4 are an estimate shaped by browser rules, not a precise headcount.
Which settings can you change?
Google documents several controls, in the Analytics interface and in the tag configuration, on its cookie customization guide:
- Cookie expiration. In the interface, you can choose how long before cookies expire, from immediately to 25 months. In code,
cookie_expiresis set in seconds, and setting it to0turns the cookie into a session cookie that expires when the browser session ends. - Cookie update. By default,
cookie_updateistrue, so cookies may be updated on each page load, which makes expiry relative to the most recent visit. Set it tofalseand expiry is relative to the first visit. - Cookie domain. By default, cookies are set on the highest-level domain possible, so a site on
blog.example.comsets cookies onexample.com. A customcookie_domainmust be an ancestor of the current domain, and Google warns that an incorrect one may result in no data being sent. - Cookie prefix. A prefix changes the cookie name, and Google warns that returning visitors will then appear as new visitors.
What happens without consent?
If you use Google's Consent Mode and analytics_storage is denied, Google states that its tags will not read or write first-party analytics cookies. Measurements without cookies can still be sent to Google Analytics for basic measurement and modeling, according to the Consent Mode documentation. In "basic" Consent Mode, no data is sent to Google at all until the user consents.
This is also why GA4 numbers can fall after a cookie banner goes live. We explain that effect in GA4 traffic dropped after your cookie banner.
Is the _ga cookie exempt from consent?
That depends on the country, the site and the setup, and the site owner stays responsible for the decision. In France, the CNIL has set specific conditions for audience measurement tools that can be used without consent; see CNIL audience measurement exemption: the exact conditions before assuming anything about GA4 on your site.
If you would rather avoid analytics cookies altogether, cookieless analytics is a different approach. Klickbee Tracking, for example, sets no cookie and keeps a random visitor id in local storage instead. That is a design choice, and consent can still apply depending on your setup and country. For a feature-by-feature view, read Klickbee vs Google Analytics 4.
FAQ
Is the _ga cookie a first-party or third-party cookie?
Google describes the GA4 cookies as first-party cookies, set on your own domain by default.
How do I delete the _ga cookie?
You can remove it in your browser's cookie settings. Deleting it only affects that browser, and the next visit will usually create a new one if the tag is allowed to set cookies.
Does _ga track me across websites?
Google's documentation describes the _ga cookie as first-party and scoped to the domain it is set on. A different site with its own Google Analytics tag sets its own cookie.
Can I set the _ga cookie lifespan to less than two years?
Yes. Google lets you set the cookie expiration from immediately to 25 months in the Analytics interface, or with cookie_expires in seconds in the tag configuration.
This is general information, not legal advice. Check your own situation with the relevant authority or a lawyer.
Want analytics without the cookie question? Create a free Klickbee account.