# What cookies does Google Analytics set, and do they need consent? - CookieRampart

Source: https://cookierampart.com/blog/what-cookies-does-google-analytics-set.html

[Home](../index.md) / [Blog](index.md) / What cookies does Google Analytics set, and do they need consent?


Google Analytics 4 primarily sets the \_ga cookie, which distinguishes individual visitors and lasts two years, and the \_ga\_<container-id> cookie, which keeps session state. Because these are analytics cookies and not strictly necessary, they require opt-in consent in the EU and UK before they are set.

## The main GA cookies

The \_ga cookie holds a randomly generated client ID that makes it possible to tell one visitor from another across sessions. The \_ga\_<container-id> cookie tracks session state such as the number of visits. Depending on your configuration, Google signals and advertising features can add more identifiers.

## Why they need consent

Analytics cookies are useful but not essential for the site to work, so under EU and UK rules they fall into the consent-required category. Regulators in Austria, France, and Italy have specifically examined Google Analytics setups, which makes this one of the most scrutinized trackers on the web.

## The compliant pattern

Load the consent banner first, block the GA tag until the visitor accepts, and pass the consent state through Google Consent Mode v2 so analytics behavior matches the choice. A visitor who declines should get no \_ga cookie at all.

## Related reading

[Do small websites need a cookie banner?](do-small-websites-need-a-cookie-banner.md)[What are strictly necessary cookies?](https://cookierampart.com/glossary/strictly-necessary.md)[Cookie consent for blogs](https://cookierampart.com/use-cases/blogs.md)[Looking for a Cookiebot alternative?](https://cookierampart.com/alternatives/cookiebot-alternative.md)

## Frequently asked questions

### What is the main cookie Google Analytics sets?

The primary cookie is used to distinguish one visitor from another so sessions and returning visits can be counted. Its name commonly starts with \_ga, and related cookies support session and campaign measurement. The exact set depends on your configuration and any advertising features you enable.

### Do analytics cookies need consent?

In opt in jurisdictions, yes: analytics cookies are not treated as strictly necessary, so they should only be set after the visitor allows that category. Some setups use cookieless or consent mode configurations to limit measurement before consent, but standard cookie based analytics needs a yes first.

### How can you check which cookies your analytics setup actually sets?

Load your site in a clean browser profile, open the storage view in developer tools, and note cookies before and after accepting the analytics category. Repeat with advertising features on if you use them, since they add their own cookies. Compare the list against your banner disclosures.

## Get a free consent audit of your website

[Free consent audit](mailto:hello@cookierampart.com?subject=Free%20consent%20audit%20-%20cookierampart.com)
