Cookie

Definition
A small file a browser stores for a site, so a return visit can be recognised and shown something different from a first one.

Why it matters

Without cookies, a hundred visits to a pricing page look like a hundred strangers. With them, a business can see that one browser came back four times, which is a very different signal from cold traffic. Cookies also power logins, baskets and the measurement behind conversion tracking.

The catch is privacy law. In the EU and the UK, a site needs consent before it sets non-essential cookies, and a banner that fires tags before anyone clicks "accept" is a compliance problem. Safari and Firefox also block third-party cookies by default, so any plan that depends on them already has gaps.

How to apply it

  • Rely on first-party cookies for anything that needs to be measured over time.
  • Put a consent tool in front of every non-essential tag, then test that declining really stops it firing.
  • Use the return-visit signal for something a person notices, such as a different page for a repeat reader or a note to sales when a target account comes back.
  • Store an identifier in the cookie and keep personal details on the server, never in the cookie itself.

What it is

A cookie is a short piece of text, usually a random identifier, that a website sends to a browser. The browser keeps it and sends it back with every later request to that site. That is how a site knows the same browser has been there before, without asking anyone to log in.

A first-party cookie is set by the site the visitor is on. A third-party cookie is set by another domain, such as an ad network whose code is embedded in the page. A session cookie disappears when the browser closes, while a persistent cookie lasts days or months. Some are essential, such as the one that keeps a basket filled. Others exist only for analytics or advertising.

Common mistakes

  • Loading analytics and advertising tags before the visitor has agreed, then relying on a banner that only records the choice afterwards.
  • Treating "essential" as a broad category. Only cookies the service cannot work without are essential. Advertising cookies, and analytics cookies in most set-ups, are not, even when the business finds them necessary.
  • Storing personal details, such as an email address, in the cookie itself, instead of an identifier matched on the server.
  • Building a plan on third-party cookies. Safari and Firefox block them by default, so attribution has gaps.
  • Never testing the declined case. Open the site, decline, and check that no non-essential cookie is set.
Worked example

Suppose a ten-person consultancy has a website with an analytics tag, an advertising pixel and a chat widget, and it has never checked which of them set cookies before a visitor consents. Its privacy lead runs a scan with Cookiebot, which lists the cookies and trackers found on each page. The scan finds two advertising cookies that fire on the first page load, before any visitor has chosen anything. The team puts those tags behind the consent banner so they fire only after a visitor accepts. The chat widget, which supports customers, stays as it is. The lead then opens the site in a private window, declines everything and checks that the advertising cookies no longer appear. Declining now works in practice, not just on paper.

Tools in the example

Some links are affiliate links: we may earn a commission at no cost to you. It never decides a ranking. How we work with partners

  1. Article

    Conversion tracking

    Recording that a visitor completed an action, often using this same cookie.

  2. Article

    Event tracking

    Logging individual actions on a page, not only the final result.

  3. Article

    First-party data

    What a business collects directly from its own visitors and customers.

  4. Article

    Attribution window

    How long a later action still counts as connected to an earlier visit.

Where it shows up

  • Measuring what works and following data to make better decisions. It tells you which changes are worth keeping and which to drop.
    22 chapters