Cherry Seed

Why does Safari delete my analytics cookies?

safari analytics cookies itp ga4 fbp cookie javascript cookies first-party cookie cap document.cookie server-set cookies

Quick Answer

Safari does not distinguish between analytics cookies and tracking cookies — Intelligent Tracking Prevention applies the seven-day JavaScript cookie cap to all first-party cookies set by client-side scripts, including GA4's _ga cookie, Meta's _fbp cookie, and any custom analytics cookies your store sets through JavaScript. From Safari's perspective, any script that sets a cookie to identify a user across sessions is performing tracking, regardless of whether the data goes to an analytics platform or an advertising network. The classification is based on mechanism, not intent. If JavaScript writes a cookie using document.cookie, Safari restricts it. The only cookies exempt from the seven-day cap are those set via HTTP response headers from a genuine first-party server.

Full Answer

Safari's ITP was designed to prevent cross-site tracking, but its implementation affects all JavaScript-set cookies equally because the technical mechanism for analytics and advertising tracking is identical.

GA4's tracking tag executes JavaScript in the browser, creates a unique client identifier, and stores it using document.cookie. Meta Pixel does the same with _fbp. A hypothetical advertising tracker doing cross-site surveillance would use the exact same mechanism. Safari cannot inspect the cookie's purpose — it can only observe the method of creation and the behavior pattern of the domain that set it.

This is why the restriction applies to analytics cookies that are not involved in cross-site tracking. The GA4 _ga cookie is a first-party cookie that only tracks behavior on your own site. It does not enable cross-site tracking. But it is set by JavaScript, which is the same mechanism that cross-site trackers use, so it receives the same seven-day restriction.

The distinction between harmless analytics and invasive tracking is a policy judgment that Safari deliberately chose not to make at the cookie level. Apple's position is that the browser should not be in the business of evaluating whether each individual cookie serves a legitimate purpose — instead, it restricts the mechanism that enables tracking and leaves it to site operators to adopt server-side alternatives for legitimate measurement.

The practical solution is the same regardless of whether the cookie serves analytics or advertising: set it from the server via HTTP headers instead of from JavaScript. Server-set first-party cookies retain their full configured lifespan because they are created through a mechanism that third-party scripts cannot exploit for cross-site tracking.

Sources

Programmatic Access

GET https://seresa.io/wp-json/cherry-tree-by-seresa/v1/seeds/683

Cite This Answer

Cherry Tree by Seresa - https://seresa.io/seed/safari-browser-privacy/safari-7day-cookie-limit-safari-delete-analytics-cookies