# First-party vs third-party cookies for analytics

> Whose domain sets a cookie decides its party. How browsers and blockers treat each, what a CNAME subdomain changes, and why it matters for long B2B deals.

A cookie is first party when the domain that sets it belongs to the site in the address bar, and third party when it belongs to anyone else. What the cookie holds makes no difference. Browsers and ad blockers treat the two very differently, and Safari blocks third-party cookies outright by default. A vendor's cookie becomes first party when the vendor serves it from a subdomain you own, set up with a CNAME record. For a B2B buyer who comes back over months, that choice decides whether they stay one visitor.

## What makes a cookie first party?

The domain that sets it, compared with the site the visitor is on. MDN puts it plainly. If the cookie's domain and scheme match the page in the address bar, it is a first-party cookie, and if they differ it is a third-party cookie ([MDN, Third-party cookies](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Third-party_cookies), checked November 2026).

"Site" here means the registrable domain, such as example.com, so every subdomain of it counts as the same site. MDN's own example is that support.mozilla.org and developer.mozilla.org are one site ([MDN, Site](https://developer.mozilla.org/en-US/docs/Glossary/Site), checked November 2026). A cookie from data.example.com is first party on www.example.com.

The contents play no part. A login cookie and an analytics cookie are both a name, a value and an expiry date. The same is true of who runs the server. The browser sees a hostname and nothing else, so one vendor's cookie can be third party on one install and first party on another, depending only on the domain it comes from.

## How do browsers treat third-party cookies?

Most browsers limit them by default, and Chrome is the main exception.

| Browser | Third-party cookies by default | Source, checked November 2026 |
|---|---|---|
| Safari | Blocked | [WebKit, Tracking Prevention](https://webkit.org/tracking-prevention/) |
| Firefox | Allowed, but kept in a separate jar for each site, so they cannot follow a person from site to site | [MDN, Third-party cookies](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Third-party_cookies) |
| Chrome | Allowed, unless the visitor is in Incognito or has turned them off in settings | [MDN, Third-party cookies](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Third-party_cookies) |

For analytics, a blocked cookie means every visit looks like a new person. A cookie kept per site still works for counting visitors on one site, but only if the browser accepts it at all, and Safari does not.

Ad blockers add a second filter. They work from lists of known tracking domains and stop the browser from contacting them. A vendor's shared domain, used by thousands of customers, is an easy entry for those lists. When the request never leaves the browser, there is no visit to count and no cookie to set.

## Why does it matter whether a script or a server sets the cookie?

Because some browsers delete cookies written by page scripts after seven days. A first-party cookie can be created in two ways. The server can send it in a Set-Cookie header with its response, or a script on the page can write it with document.cookie ([MDN, Using HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies), checked November 2026).

WebKit, the engine behind Safari, deletes all cookies created in JavaScript after seven days without user interaction ([WebKit, Tracking Prevention](https://webkit.org/tracking-prevention/), checked November 2026). Being first party does not exempt a cookie from that rule.

Google Analytics is the common case. GA4's _ga cookie is first party, it is set by the GA4 JavaScript tags, and its default expiry is two years ([Google, Cookie usage on websites](https://support.google.com/analytics/answer/11397207), checked November 2026). In a browser that applies WebKit's rule, that two-year expiry does not hold. A visitor who stays away for more than a week comes back as a new one.

## What does a CNAME subdomain change?

It puts the vendor's server on a hostname inside your own site, so its cookie becomes first party. You add one DNS record, a CNAME, that points a name such as data.example.com at the vendor's server. The browser asks for data.example.com, gets the vendor's response, and files the cookie under your site. It never sees the vendor's domain.

The subdomain also lets the vendor set the cookie from its server, in the response, instead of from a script on your page.

| | Vendor's shared domain | A subdomain you own |
|---|---|---|
| The cookie is | Third party | First party |
| In browsers that block third-party cookies | Refused | Accepted as one of your own |
| On ad blocker filter lists | Likely, one domain serves every customer | Far less likely, the name is unique to your site |
| Setup | Paste a script tag | Paste a script tag and add one DNS record |

The trade is a few minutes in your DNS settings. For most sites that is the only extra step.

## What does this mean for a long B2B sales cycle?

The cookie has to outlast the gaps between a buyer's visits, or one buyer turns into several strangers and the campaign that found them loses the credit.

Take one buyer, as an example. Kate Brennan at Calder Payroll clicks a LinkedIn ad on day 0. She comes back from a search on day 12, types the address in on day 40, looks at pricing on day 150 and requests a demo on day 260. The gaps between visits are 12, 28, 110 and 110 days, all longer than a week.

| How the visitor cookie is stored | Visitors counted for Kate's five visits | Who gets credit for the demo request |
|---|---|---|
| Third-party cookie, refused by the browser | 5 | Whatever brought the last visit |
| First-party cookie written by a script, in a browser that applies WebKit's seven-day rule | 5 | Whatever brought the last visit |
| First-party cookie the browser keeps for two years after the last visit | 1 | The LinkedIn ad, from day 0 |

In the first two rows the LinkedIn campaign shows one visitor who left and never came back. Nine months later the demo request lands on a typed-in visit with no campaign behind it. With a long sales cycle that error runs through every report, because the gaps between a buyer's visits are often longer than a week.

A cookie that lasts lets you tie a deal back to the month and campaign of the buyer's first visit, which is how the [article on judging campaigns before leads arrive](/blog/judge-b2b-ad-campaigns-before-leads) suggests grouping deals. And it keeps the visit history whole, so you can see how a buyer's engagement built up over the months before they asked for anything.

No cookie survives a visitor who clears their cookies or switches to another browser or device. That visitor is lost while they are anonymous. Once they identify, by a form, a sign-in or a typed email, their visits in each browser join up under the same person.

## How Numbat sets its cookie

Numbat serves its script from a subdomain you own, such as data.example.com, set up with one CNAME record ([Install the script](/docs/tracking/install-the-script)). Its visitor cookie is set by Numbat's server in the response, never by the page script, and script on your pages cannot read it. The cookie is refreshed on every visit, so Numbat remembers a visitor for two years after their last visit. That is how it keeps [a buyer as one visitor across a long sales cycle](/attribution), with the campaign that first brought them in.

If you install the standard tag first, it loads from Numbat's own domain, and the cookie is third party there. Some browsers refuse it and some blockers stop it. Switching to your own subdomain later leaves no gap in data.

{/* Screenshot: one visitor's timeline with visits months apart, from a first LinkedIn click to a demo request, example data. Add when the image is made. */}
