Journal · GA4 & measurement

What cookies does Google Analytics 4 set?

29 November 20266 min readBy Walter Masseroni Gonzalez, Leon Aves, Daragh McCarthy and Alana Rossi

Google Analytics 4 sets two first party cookies: _ga, which tells one browser from another, and _ga_<container-id>, a session cookie named after your data stream. Both last two years by default, renewed on every visit, though Safari cuts that to seven days. Link Google Ads and the tag adds advertising cookies too, such as _gcl_au.

Which cookies does Google Analytics 4 set?

Google’s own table, in the GA4 help article on cookie usage, lists exactly two for a site that runs the Google tag:

  • _ga: a random client ID plus the time it was first set. GA4 uses it to count the same browser as one user across visits.
  • _ga_<container-id>: the session cookie, named after your data stream’s measurement ID without the G-. It holds the session number and when the last hit happened, which is how GA4 knows whether a page view starts a new session.

Both are first party: they sit on your domain, not on google.com. The tag writes them on the highest level of domain it can, so on shop.example.com you will find them on .example.com. That matters later, when you try to delete them.

When the GA4 property is linked to Google Ads, the same tag also sets Google’s advertising cookies, the ones starting _gcl_. Those belong to Google Ads measurement, not to analytics, and they are covered by Google’s separate advertising cookie list.

Two analytics cookies, plus the Ads ones once linked.

CookieWhat it doesCategory
_gaTells browsers apart, two yearsAnalytics
_ga_<container-id>Keeps the session, two yearsAnalytics
_gcl_au and other _gcl_Google Ads measurement, when linkedAdvertising
The first two rows are Google’s GA4 cookie table with its default lifetimes. The last row appears only when the property is linked to Google Ads, and its lifetimes come from Google’s advertising cookie list, not this one.

What happened to _gid, _gat and _gac?

They came from Universal Analytics. _gid was a 24 hour user cookie, _gat throttled requests and _gac carried campaign data. GA4’s table does not list any of them, and Universal Analytics has stopped processing data: standard properties in July 2023, the last 360 properties in July 2024. When we audit a site and still find _gid, it almost always means an old analytics.js snippet or a forgotten tag is still loading. Remove the tag rather than listing the cookie.

How long do Google Analytics cookies last?

Two years by default, counted from the last visit, because each hit pushes the expiry forward. In the data stream’s Google tag settings you can override it with anything from immediately to 25 months, and choose whether the clock runs from the first visit or the most recent one.

The browser has the last word. Google’s article notes a maximum of 400 days in Chrome and 7 days in Safari; Chrome caps every cookie at 400 days, and Safari’s limit applies to cookies written by page scripts, which these are. So the honest lifetime for a Safari visitor is a week, whatever your settings say, and a Safari visitor who returns after more than seven days without a visit is counted as a new user. Teams often read that as a tracking fault. It is the browser doing what it says.

Are Google Analytics cookies strictly necessary?

No. They measure how people use the site; the site works the same without them. They belong in the analytics or statistics category of your banner, and in the EU they need consent before they are written. The UK’s Data (Use and Access) Act 2025 added a limited exception for statistics, with conditions that include clear information and an easy way to object; read the ICO’s guidance on storage and access technologies before you rely on it. Our post on which consent category a script goes in covers the edge cases.

With Google’s consent mode, the cookie question has a precise answer: while analytics_storage is denied, the tag does not write or read these cookies. In advanced mode it still sends cookieless pings; in basic mode it sends nothing until consent. Whether GA4 can still be useful in that state is its own question, answered in can Google Analytics work without cookies.

  1. Read what your site really sets

    Accept all on a clean browser profile, load a few pages, and copy every cookie name and expiry from the storage panel. Do it again after rejecting, so you know what appears without consent.

  2. Match each name to its tool

    _ga and _ga_ followed by your stream's ID are Google Analytics. Names starting _gcl_ are Google Ads, which GA4 adds when the two are linked. Anything else belongs to another tag.

  3. Write the row for each cookie

    Name, provider, purpose in one plain sentence, lifetime as your site sets it, and category. If you changed the expiry or added a prefix, write your value, not Google's default.

  4. Put them in the right category

    Analytics cookies go under analytics or statistics, the Google Ads ones under advertising. Neither belongs under strictly necessary.

  5. Check it again after every tag change

    A new Google Ads link, a cookie prefix or a changed expiry changes the list. Rerun the first step whenever the tags change, and at least once a year.

The most common gap we see is a cookie policy copied from a template that lists _ga, _gid and _gat with Universal Analytics lifetimes, on a site that has run GA4 for two years. The names your site sets are the only ones that belong in it. To check whether any of them is written before the visitor chooses, see is a tag really setting cookies before consent.

How Velo handles it

Velo files _ga and _ga_ cookies under analytics and the _gcl_ cookies under advertising. When a visitor withdraws one of those categories, it sends the denied signal first and then deletes those cookies on the current host and every parent domain up to the registrable one, with path=/. Why that order matters is in why a tracking cookie comes back after rejection.

Common questions

What cookies does Google Analytics 4 set?

Two first party cookies: _ga, which distinguishes users, and _ga_ followed by your stream ID, which keeps session state. Both last two years by default, though browsers can cap that. Linking Google Ads adds advertising cookies such as _gcl_au.

Does GA4 still use the _gid cookie?

Google's GA4 cookie table does not list it. _gid, _gat and _gac came from Universal Analytics, which no longer processes data, so finding them usually means an old tag is still on the page.

How long do Google Analytics cookies last?

Two years by default, and the clock restarts on each visit. You can set anything from immediately to 25 months, and browsers cap it anyway: Chrome at 400 days, Safari at 7 days for cookies written by page scripts.

Are Google Analytics cookies strictly necessary?

No. They measure visits, so they go in the analytics or statistics category, not necessary. Under EU rules they need consent before they are written; the UK has a narrow statistics exception with conditions.

What should a cookie policy say about Google Analytics cookies?

For each cookie: its exact name, Google as the provider, what it does, how long it lasts on your site, and its category. List the names your site really sets, including any prefix or changed lifetime.

Keep reading


Start with a scan

See what your homepage already loads before you install anything. The free scanner reads the page and your public Tag Manager container.


A first pass, not a verdict. Four checks on your homepage, and we open your container.
V
Free scanNo account needed

Free for one site and 1,500 monthly sessions. Pro from €5 a month, plus VAT, for unlimited sites.

Step by step installs for WordPress, Shopify, Webflow, Wix and more.

Free for one site

Banner, scan and consent records for one site, free. Pro from €5 a month, plus VAT, for unlimited sites.