Dimensions and metrics

[GA4] Cookie usage on websites

This article is about cookies usage for Google Analytics 4 properties. To learn about cookies for Universal Analytics, see this article instead.

The gtag.js JavaScript library uses first-party cookies to distinguish unique users as well as unique sessions from a single user. The library does not require you to set cookies to transmit data to Google Analytics.

Browsers enforce limitations on the lifespan of first-party cookies if a user does not make a return visit (maximum of 400 days for Chrome and 7 days for Safari).

gtag.js cookies

The following table describes each cookie set by gtag.js. To learn more about the data that Analytics collects, see Safeguarding your data.

Cookie name Default expiration time Description
_ga 2 years Used to distinguish users.
_ga_<container-id> 2 years Used to persist session state.

You need the Editor role to use this feature. To override default cookie expiration and cookie update settings:

  1. In Admin, under Data collection and modification, click Data streams.
  2. Click the data stream for your website, then under Google tag, click Configure tag settings.
  3. Under Settings, click Show all.
  4. Click Override cookie settings.
  5. Select the Override default cookie settings checkbox.
  6. Under Cookie expiration select how long before cookies expire (from immediately to 25 months).
  7. Under Cookie update select either Set cookie expiration time relative to most recent visit or Set cookie expiration time relative to first visit.
  8. Click Save.

If you need to customize additional cookie settings, see Cookies and user identification.

Cookie settings configured using the global site tag or Google Tag Manager override settings configured in the Analytics interface.

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
1090424288128877720
true
Search Help Center
true
true
true