Analytics and Data Beginner

Cookie

A cookie is a small file a website stores in a visitor's browser to remember them across sessions, used for analytics, personalisation and ad targeting.

A cookie is a small text file that a website stores in a visitor’s browser, used to remember information about that visitor across sessions and page loads, enabling everything from login persistence to analytics tracking and ad targeting.

The web has no memory by default. When you visit a website, close the tab and return an hour later, the server has no idea you were there before. Cookies solve this by storing a small piece of identifying information in your browser that gets sent back to the server on your next visit. For the server, the cookie says: this browser was here before, here’s what we know about it.

For marketers, cookies are foundational infrastructure. Your analytics platform uses a first-party cookie to count returning visitors and stitch together a user’s sessions. Your shopping cart works because a cookie remembers what you added even after navigating away. Advertising retargeting works by setting a cookie when someone visits your site, then reading it later when that browser appears on another site in the same ad network.

The marketing conversation around cookies over the past several years has been almost entirely about their decline, specifically the third-party cookie. Safari blocked third-party cookies by default in 2017. Firefox followed. Chrome, which is the dominant browser, introduced user-level controls and has been working toward reducing reliance on third-party cookies for cross-site tracking. The ad industry’s targeting and measurement infrastructure, built on third-party cookies, is being rebuilt as a result.

Setting a cookie. When your browser loads a page, the server can include a Set-Cookie header in its response. The browser stores the cookie and sends it back with every subsequent request to that domain. The cookie includes the data itself, an expiry date and domain restrictions.

First-party cookies. Set by the domain you’re visiting. Used for sessions, logins, preferences and first-party analytics (like Google Analytics’ _ga cookie). First-party cookies work in all browsers and are not subject to the same restrictions as third-party cookies.

Third-party cookies. Set by a domain different from the one you’re visiting, typically via an embedded script or pixel. The classic example is an advertising pixel: a brand puts a Meta pixel on their site, Meta sets a third-party cookie in your browser, and Meta can then recognise you on other sites that also have the Meta pixel. This is how cross-site retargeting and conversion tracking have traditionally worked.

Expiry. Session cookies expire when you close the browser. Persistent cookies have an expiry date set by the issuer, which can range from days to years.

A user visits a shoe retailer, views a running shoe and leaves without buying. The site’s Meta pixel sets a third-party cookie. The next day the user visits a news site, where a Meta ad appears showing the exact running shoe they viewed. The retargeting is powered by the cookie reading: this browser looked at this product. As third-party cookies are phased out, this type of targeting requires server-side tracking and first-party data as replacements.

Cookies are the technical layer underneath most of what analytics and digital advertising have done for twenty years. Understanding what they are and how they differ (first-party versus third-party) explains why the deprecation of third-party cookies is such a significant change, and why the marketing industry is investing in server-side tracking, consent management and first-party data infrastructure to replace what they lose.

Frequently Asked Questions

What is the difference between first-party and third-party cookies?

A first-party cookie is set by the website you are actually visiting and is stored under that site's domain. It is used for things like keeping you logged in, remembering your shopping cart and running your site's own analytics. A third-party cookie is set by a different domain, typically an advertising or analytics service embedded in the page. It can track you across many different websites. Third-party cookies have been restricted by Safari and Firefox for years and are increasingly controlled by Chrome, which is why they're being phased out for ad targeting.

Are cookies harmful?

Not inherently. Cookies that keep you logged in, remember your preferences or power a shopping cart are useful and expected. The controversy around cookies is mainly about third-party tracking cookies that follow you across the web without clear consent, building profiles of your behaviour for advertising purposes. Privacy regulations like GDPR require websites to obtain consent for non-essential cookies, which is why cookie banners became ubiquitous.

What happens when cookies are blocked or deleted?

Analytics platforms lose the ability to recognise returning visitors, so session and user counts become less accurate. Personalisation features that rely on cookie data stop working. For advertising, blocked third-party cookies mean advertisers can no longer track conversions or retarget users across sites using the traditional method. This is driving investment in server-side tracking, first-party data strategies and privacy-preserving measurement alternatives like the Privacy Sandbox.

Consulting & Strategy

Need help putting this concept into practice on your campaigns? Share your current targets and I will suggest the right approach.

Discuss your campaigns