What is cookie data? How websites, GA4, Meta Pixel, and TikTok Pixel define cookies — and why the numbers never match
If you’ve ever visited a website and seen a banner that says “This site uses cookies,” you’ve encountered the digital breadcrumb that powers the modern web. Cookie data refers to small text files (usually under 4KB) that a website stores on a user’s browser. These files contain key-value pairs like session_id=abc123 or user_pref=darkmode. Cookies are the reason you stay logged into Gmail, why your shopping cart doesn’t empty when you navigate away, and how ads follow you around the internet. But not all cookies are equal. Google Analytics 4 (GA4), Meta Pixel, and TikTok Pixel each define, read, and write their own cookies with different purposes, lifetimes, and attribution windows. This article breaks down how each platform handles cookie data, why user counts differ between GA4 and ad platforms, and what happens when two websites share the same Google tag. Plus, a real‑world look at retargeting through the user’s eyes — written the way an American marketer would explain it over coffee.
How a website defines a cookie (the old‑school way)
A website sets a cookie via the HTTP response header Set-Cookie. Here’s a typical example from a login page:
HTTP/1.1 200 OK
Set-Cookie: session_id=9a2b3c4d; Domain=example.com; Path=/; Secure; HttpOnly; SameSite=Lax; Max-Age=3600
Set-Cookie: user_pref=theme_dark; Domain=example.com; Path=/; Max-Age=31536000
The browser stores these and sends them back on every subsequent request to example.com via the Cookie header. First‑party cookies (same domain as the website) are used for authentication, preferences, and analytics. Third‑party cookies (set by a different domain, like facebook.com on example.com) are used for cross‑site tracking. Each cookie has attributes: Domain (who can read it), Path, Secure (HTTPS only), HttpOnly (blocked from JavaScript), SameSite (anti‑CSRF), and Max-Age or Expires.
How Google Analytics 4 (GA4) defines cookies
GA4 uses first‑party cookies (set on your own domain) to identify unique users. The primary cookie is _ga (expires after 2 years), which stores a client ID like GA1.2.123456789.1700000000. A second cookie, _ga_<container-id>, stores session information. Unlike Universal Analytics, GA4 does not rely on third‑party cookies — it’s designed to work with first‑party contexts and can also operate without cookies using Google Signals and user‑provided data. When a user visits your site, GA4’s JavaScript (gtag.js) checks for existing _ga cookie. If none exists, it generates a new random client ID and sets the cookie. This client ID is then attached to every event (page_view, click, purchase) sent to Google’s servers.
// GA4 sets a cookie that looks like this:
_ga=GA1.2.123456789.1700000000; Domain=example.com; Path=/; Expires=Tue, 12 Apr 2027 12:00:00 GMT; SameSite=Lax
// The client ID is derived: 123456789.1700000000
How Meta Pixel (Facebook) defines cookies
Meta Pixel sets both first‑party (on your domain) and third‑party cookies (on .facebook.com). The primary first‑party cookie is _fbp (Facebook Browser ID) — a first‑party cookie that stores an anonymous identifier with a 90‑day expiration. When the pixel fires, it reads or creates _fbp and also attempts to read third‑party Facebook cookies (like c_user) if the user is logged into Facebook. The third‑party cookies allow Meta to match the website visitor to a Facebook user profile. Because of browser restrictions (ITP, ETP), the third‑party cookie often gets blocked. That’s why Meta heavily pushes the Conversions API as a server‑side fallback.
// _fbp cookie (first‑party)
_fbp=fb.1.1700000000000.123456789; Domain=example.com; Path=/; Max-Age=7776000 (90 days)
// If third‑party allowed, Meta also reads:
.datr, c_user, xs (under .facebook.com domain)
How TikTok Pixel defines cookies
TikTok Pixel (ttq) uses a first‑party cookie named _ttp (TikTok ID) with a 365‑day expiration. It also attempts to set a third‑party cookie under .tiktok.com for cross‑site matching. The _ttp value is a randomly generated UUID. Unlike Meta, TikTok’s pixel relies more heavily on first‑party identifiers and browser fingerprinting (user agent, screen resolution, timezone) when cookies are blocked. Their server‑side API (Events API) is the recommended method for reliable attribution.
// _ttp cookie (first‑party)
_ttp=XYZ123abc-4567-8901-def2-34567890abcd; Domain=example.com; Path=/; Max-Age=31536000 (1 year)
Real‑user example: Sarah shops on “OutdoorGear.com”
Let’s follow Sarah, a 32‑year‑old from Austin, Texas. She visits OutdoorGear.com using Chrome (with third‑party cookies still enabled). The site has GA4, Meta Pixel, and TikTok Pixel installed. Here’s what happens behind the scenes:
- GA4: Checks for
_gacookie. None exists → creates new client ID:GA1.2.987654321.1700000000. All page views and a “view_item” event (she looks at a North Face jacket) get this ID. - Meta Pixel: Checks for
_fbp. None → createsfb.1.1700000000000.987654321. Also checks for third‑party Facebook cookies. Sarah is logged into Facebook on the same browser, so the pixel readsc_userandxs. Meta now knows that the visitor with_fbpis also Facebook user “Sarah Johnson (ID 123456789)”. - TikTok Pixel: Checks for
_ttp. None → createsXYZabc-.... It tries to read third‑party TikTok cookies, but Sarah hasn’t visited TikTok recently, so no match.
Sarah adds the jacket to cart but doesn’t buy. She leaves the site. Later that day, she sees a Facebook ad for the same jacket (retargeting). On TikTok, she sees a different ad for a similar jacket (using the _ttp ID for retargeting, but since there was no cross‑site match, TikTok uses interest‑based targeting instead).
Why GA4 user counts differ from Meta Pixel and TikTok Pixel
_ga client ID. No cross‑domain tracking by default. GA4 counts a user even if they block third‑party cookies (since it’s first‑party). GA4 also has a 24‑hour session window and can deduplicate across devices only if Google Signals is enabled (user logs into Google)._fbp / _ttp) and third‑party cookies (if available). If third‑party is blocked, they rely on browser fingerprinting and server‑side matching. Meta often shows lower “website unique users” than GA4 because (a) Safari blocks third‑party cookies, (b) users with ad blockers, and (c) attribution windows differ (GA4 uses 2 years, Meta uses 90 days for _fbp).Two websites, same Google tag — same cookie?
Short answer: No, not by default. GA4’s _ga cookie is scoped to the domain that sets it. If you have two domains — say store.com and blog.com — and both use the same GA4 measurement ID (G-XXXXXXXX), each domain will set its own separate _ga cookie. The client IDs will be different. However, you can enable cross‑domain measurement in GA4 by adding both domains to the “Configure domains” list and using the gtag('config', 'G-ID', { 'linker': { 'domains': ['store.com', 'blog.com'] } }). This passes the client ID via URL parameters (_gl parameter) when a user clicks a link from one domain to the other. Without this, GA4 treats the same user as two separate users. For Meta and TikTok pixels, cross‑domain tracking is even harder — they rely on third‑party cookies which are being phased out. The recommended solution is a Customer Data Platform (CDP) or server‑side tagging.
Cookie retargeting in action: what the user actually sees
“Okay, so last Tuesday I was on OutdoorGear.com looking at a $350 Patagonia puffer jacket. I didn’t buy it — I just clicked around, read reviews, then closed the tab. No big deal. Then, Wednesday morning I’m scrolling through Facebook, and BOOM — there’s the exact same jacket, same color, even the same discount code. I think, ‘creepy but convenient.’ So I click the ad, go back to the site, and this time I buy it. Later that day, I’m on TikTok, and I see an ad for a waterproof backpack from the same brand. That’s the pixel doing its job.”
Cookie comparison: GA4 vs Meta Pixel vs TikTok Pixel
| Feature | GA4 (_ga) | Meta Pixel (_fbp) | TikTok Pixel (_ttp) |
|---|---|---|---|
| Cookie type | First‑party | First‑party + third‑party | First‑party + third‑party |
| Default expiration | 2 years | 90 days | 365 days |
| Value format | GA1.2.[random].[timestamp] | fb.1.[timestamp].[random] | UUID |
| Attribution windows | Last‑click non‑direct | 1‑day click, 7‑day view | 1‑day click, 7‑day view |
| Survives ITP (Safari)? | Yes (first‑party) | Partial (7‑day limit) | Partial (7‑day limit) |
// Open your browser console on any site with GA4 + Meta Pixel
// Read GA4 client ID
document.cookie.split('; ').find(row => row.startsWith('_ga='));
// Output: "_ga=GA1.2.123456789.1700000000"
// Read Meta _fbp
document.cookie.split('; ').find(row => row.startsWith('_fbp='));
// Read TikTok _ttp
document.cookie.split('; ').find(row => row.startsWith('_ttp='));
// See all cookies (caution: may be truncated)
console.log(document.cookie);
The future: cookieless tracking and first‑party strategies
With Chrome phasing out third‑party cookies and Safari/Firefox already blocking them, the era of cross‑site cookie tracking is ending. GA4 has already adapted (first‑party only). Meta and TikTok are pushing Conversions API (server‑side) and first‑party pixels that use browser fingerprinting and hashed personal data (email, phone) for matching. The new standard is first‑party data — collecting user identifiers directly (with consent) through login, email signups, or CRM uploads. Google’s “Privacy Sandbox” proposes alternatives like Topics API and FLEDGE, but adoption is slow. For now, marketers must expect discrepancies between analytics and ad platforms. The wise strategy: use server‑side tagging, a CDP, and accept that 100% deterministic tracking is dead.
Cookie data is still powerful — but treat it like a fading candle
Cookie data powers personalization, analytics, and retargeting, but the landscape is shifting under our feet. GA4’s first‑party cookies will survive, while Meta and TikTok pixels lose cross‑site superpowers. Smart businesses are moving to server‑side tracking, first‑party identity graphs, and consent management platforms. The example of Sarah shows that retargeting works — for now. But by 2027, the cookie as we know it will be a relic. The winners will be those who build direct relationships with users (email, logins, loyalty programs) and respect privacy choices. Cookie data isn’t dead, but it’s no longer the king of the hill.