Privacy
Google Analytics cookies explained: what they are for, and what a banner decides
What the Google Analytics 4 cookies are for, why they are first-party, and why a cookie banner depends on the whole page, not one script.
The CrispStats team · · 8 min read
In short
A Google Analytics cookie is not the whole of what Google Analytics collects, and it is not the whole of what your page stores. This post is only about the cookies Google’s own GA4 documentation names, what they are for, and why a banner decision is bigger than one script. It is general information, not legal advice.
The cookie names and lifetimes below are from Google’s page, GA4 cookie usage on websites, read on 29 November 2026. What else a default install collects, including when cookies are withheld, is in what data Google Analytics collects. The difference between a first-party cookie and a third-party cookie, and how browsers treat each, is in first-party versus third-party cookies. This page does not invent further cookie names, and it does not repeat those two guides.
Which cookies does Google Analytics 4 set?
Google’s documentation names two cookies for the GA4 JavaScript tags: _ga, and _ga_ followed by a container id. Both have a default expiration of 2 years. The page says these tags use first-party cookies to distinguish unique users and unique sessions from a single user.
| Cookie | Default expiration | What Google's page says it is for |
|---|---|---|
_ga | 2 years | Used to distinguish users |
_ga_<container-id> | 2 years | Used to persist session state |
The container id is part of the second name, so the cookie is not the four characters _ga_ on their own. Google writes it as _ga_ followed by the container id. If a cookie list on your site shows further names, they are not in this table: they may come from a linked Google Ads account, from another tag, or from something else on the page. Google’s advertising and measurement cookies page is where Google points for the extra cookies set when Ads is linked. This post does not copy names out of it.
What is each cookie for?
_ga is there to distinguish users, and _ga_<container-id> is there to persist session state, which is Google’s wording on the cookie page. Together they are how the tags tell one browser from another and keep a session attached to that browser across page views.
Distinguishing users means the same browser can be counted once across visits, for as long as the cookie lasts, instead of looking like a new visitor on every request. Persisting session state means hits that belong to one sitting stay in that sitting. Neither cookie, on this description, is the page address, the referrer, or the location derived from an IP address. Those are part of collection, and they are listed in what data Google Analytics collects, which is the right page if the question is the payload rather than the cookie.
Are Google Analytics cookies first-party or third-party?
Google’s cookie page says the GA4 tags use first-party cookies. A first-party cookie belongs to the site in the address bar. A third-party cookie belongs to some other domain.
The script can be loaded from Google and still write a first-party cookie on your domain. That is why blocking third-party cookies does not, by itself, remove _ga. First-party versus third-party cookies explains that split, and what Safari, Firefox, Chrome and Edge do to each kind. This page does not retread the browser table. First-party is a statement about whose domain the cookie is on. It is not a statement that the cookie is exempt from consent, and it is not a statement that the cookie only does something harmless.
Does Google Analytics have to set a cookie to send data?
No. Google’s cookie page says the libraries do not require you to set cookies to transmit data to Google Analytics. The cookies are how the tags distinguish users and sessions. Transmission of a hit is a separate sentence on the same page.
That sentence is easy to over-read. It does not say a hit without cookies is empty, and it does not say a hit without cookies is harmless. What Google describes sending when a visitor has not accepted cookies depends on the consent setup, and that description is already in what data Google Analytics collects. Use that page for the contents of those hits. Use this page for the named cookies. If the cookies are absent, you should not assume the tag sent nothing, and you should not assume it sent the same identifier it would have stored for two years.
How long do the cookies last?
Google’s table gives both cookies a default expiration of 2 years. The same page says browsers enforce their own limits on first-party cookies when a user does not make a return visit: a maximum of 400 days for Chrome and 7 days for Safari.
So the default on the cookie and the life the browser allows are not the same number. A two-year default can be cut by the browser under the condition Google states, which is a user who does not return. Google also lets you override the expiration, from immediately to 25 months, and it says cookie settings in the global site tag or in Google Tag Manager override the settings in the Analytics interface. The finer browser-by-browser rules, beyond the sentence on Google’s cookie page, are in first-party versus third-party cookies. Changing the expiration does not change the category of the cookie.
Does the banner decision depend on the analytics script alone?
No. A cookie banner decision depends on the whole page: every script that stores or reads something on the device, and every collection purpose, not on the Google tag in isolation. Removing or keeping one analytics script does not settle the page.
Example. A shop loads the Google tag, a chat widget that sets its own cookie, and an ad pixel. The banner is the visitor’s answer to that combination. Accepting or refusing it is not a switch labelled only for analytics, unless you built the banner that way and the other tools really do wait. Do you need a cookie banner for analytics is the longer treatment of the analytics part of the question, by region and with the limits of what a vendor can claim. It is still not a ruling on your page. Your counsel looks at the full list. This post will not tell you that you do, or do not, need a banner.
- List every cookie in a private window, before and after any consent click, not only the two in Google’s table.
- Include embeds, chat, ads and payment widgets. They are part of the page even when they are not part of the analytics tag.
- Do not treat a first-party label as the end of the question. Purpose is what the banner is about, which the first-party guide says plainly.
What extra cookies appear when Google Ads is linked?
Google’s cookie page says that when a GA4 property is linked to a Google Ads account, the tags set additional cookies, used to give Google Ads a more reliable way to measure interactions with your business. It does not list those names in the GA4 cookie table. It points to a separate advertising and measurement cookies page.
That is as far as this post goes on names. The table above stays at the two cookies Google lists for GA4 tags. If Ads is linked, expect more cookies than those two, and read them on Google’s advertising and measurement cookies page rather than from a secondary summary. Linking Ads is also a change to the banner question, because the page is no longer ‘analytics only’. The collection side of advertising features is part of what data Google Analytics collects.
What is different if the analytics tool sets no cookies?
A tool that sets no cookies does not add _ga or _ga_<container-id> to the page, and it does not distinguish returning users for two years with those cookies. CrispStats sets no cookies in its default setup, does not store IP addresses, and does not store raw user agents. How the counting works without a cookie is in cookieless analytics explained. The product side of that setup is cookieless analytics.
The absence of an analytics cookie is not, by itself, the absence of a banner. Other tools on the same page can still store something, which is the point of the previous section. A cookieless analytics script also does not erase Google’s cookies if the Google tag is still on the page. Run one or the other, or know that you are running both and that the banner still has to account for whatever remains. The trade-off, spelled out in the cookieless guide rather than here, is that a visitor who returns tomorrow is not recognised by the default daily hash.
Terms in this guide
Free tools
- Bounce rate calculatorCalculate bounce rate from sessions, under the classic single-page rule or the GA4 definition, and see how many bounces stand between you and a target.
- Conversion rate calculatorWork out your conversion rate from visitors and conversions: conversions ÷ visitors × 100. With the formula, a worked example and what a target rate needs.
- Engagement rate calculatorCalculate engagement rate the GA4 way for a website, or the social media way for a post by reach, impressions or followers, and see why the two differ.
More guides
All guides- Privacy · 10 minWhat data does Google Analytics collect? A table from Google's own documentationWhat Google Analytics 4 collects by default, from cookies and page data to location and device, what it does not store, and what you can switch off.
- Privacy · 9 minFirst-party vs third-party cookies: the difference, and what browsers block nowFirst-party cookies belong to the site you visit, third-party cookies to another domain. What Safari, Firefox, Chrome and Edge block now, from their own docs.
- Privacy · 10 minDo you need a cookie banner for analytics?When analytics needs consent: what the device storage rule covers, where GDPR comes in, and a checklist. General information, not legal advice.