Sub topic 7
Building a first-party data foundation
This chapter assumes you know basic digital marketing concepts (campaigns, conversions, funnels), have used web analytics and a tag manager, and understand what a cookie is. Earlier chapters covered why third-party signals are shrinking and how consent works. Here you build the replacement: data you collect directly, with permission, and can use.
What first-party data is
First-party data is information you collect directly from people through your own properties and interactions. It is collected under your own domain, apps, stores, and support channels. It is not bought from a broker and not inferred by an ad network that follows people across sites.
Common sources:
- Website and app behavior on your own domain, such as page views, product views, and cart events.
- Account and purchase records, such as orders, returns, and subscription status.
- Email and SMS engagement, such as sends, opens, clicks, and unsubscribes.
- Customer service and sales conversations, logged in a CRM (customer relationship management system).
- Declared preferences, which the next chapter covers as zero-party data.
First-party does not mean "free of rules." You still need a lawful basis, and in many regions consent, to collect and use it. A cookie set by your own site is first-party, yet browsers still limit how long some of them last.
First-party cookies and their limits
Many teams assume that moving a tracking cookie to their own domain solves the problem. It helps, but only partly. Safari's Intelligent Tracking Prevention caps the lifetime of cookies written by JavaScript (document.cookie), and it can also limit cookies set by a third-party server that is disguised under your domain. Cookies set by your own server through an HTTP Set-Cookie header generally last longer.
// Set a first-party cookie from your own domain, only after the visitor has consented.
function setFirstPartyId(consented) {
if (!consented) return;
const id = crypto.randomUUID();
const maxAge = 60 * 60 * 24 * 90; // 90 days
document.cookie = `visitor_id=${id}; Max-Age=${maxAge}; Path=/; Secure; SameSite=Lax`;
}The function sets nothing unless the visitor has consented. The cookie asks for 90 days, but a browser may shorten that lifetime for script-set cookies. Treat the cookie as a convenience for recognizing a returning browser. It is not a durable identity.
A durable identity comes from something the person gives you: an email address, a phone number, or a login.
The identity spine
A first-party data foundation needs a stable way to say "these events belong to the same customer." Teams usually build this in layers.
- Anonymous ID. A first-party cookie or app install ID that groups events from one browser or device. It is short-lived and can be lost.
- Known ID. A customer ID created when someone signs up, logs in, subscribes, or buys. It is stable across devices.
- Identity link. The moment an anonymous ID meets a known ID, for example at login, you store the link. Earlier anonymous events can then be attached to the person, if consent covers it.
The value of the foundation depends on how often you can reach step 2. A site where 3% of visitors log in has a weak spine. A site with logins, a loyalty program, and receipts by email has a strong one.
Where the data lives
You need one place where these records meet. The options differ in cost and effort.
| Option | What it is | Good fit | Main risk |
|---|---|---|---|
| CRM | System of record for contacts, deals, and service history | Small teams, B2B | Weak on web and app events |
| Customer data platform (CDP) | Tool that collects events, resolves identity, and sends audiences to other tools | Many channels, many tools | Cost, and a new system to govern |
| Data warehouse | Central database for all company data, queried with SQL | Teams with analysts or engineers | Needs engineering to activate the data |
| Warehouse plus reverse ETL | Warehouse as the source of truth, with a tool that pushes tables back out to ad and email tools | Mature data teams | Pipeline upkeep |
Start with what you have. A CRM with clean contact records and consistent fields beats a CDP fed by messy data.
Collecting data worth having
A foundation fails more often from poor design than from missing tools. These practices keep it useful.
- Define a purpose for each field. If you cannot name the campaign or decision that uses a field, do not collect it. Fewer fields means less risk and cleaner data.
- Give every event a consent state. Store whether the person agreed to analytics, marketing email, or ad use, and when. Filter on that state before every export.
- Use a naming convention. Pick one pattern, such as
order_completed, and use it in the site, app, and warehouse. - Capture campaign source in your own data. UTM parameters are a first-party way to record where a visit came from.
https://example.com/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_saleUTM parameters record the campaign on that visit. They cannot link two separate visits to one person unless the person also logs in or otherwise identifies themselves. Keep values lowercase and consistent, because Email and email become two rows in a report.
- Collect at moments of value. People hand over an email address for a receipt, a back-in-stock alert, a saved cart, or a member price. A bare "subscribe to our newsletter" box converts less well than an offer tied to something they want.
Activating first-party data
Once data is joined and consented, you can use it in four main ways.
- Owned channels. Email, SMS, and push notifications reach people without any ad platform in the middle.
- Onsite and in-app experience. Recommendations, content order, and offers based on past behavior and account status.
- Audience uploads. Ad platforms accept lists of customers matched by hashed identifiers, so you can target, exclude existing customers, or build lookalike audiences. Send only people whose consent covers ad use.
- Measurement inputs. Customer records feed conversion uploads, lifetime value models, and incrementality tests, covered in later chapters.
Platforms typically match on normalized, hashed values. Normalizing means trimming spaces and lowercasing, so the same person always yields the same hash.
import hashlib
def hash_email(email: str) -> str:
"""Normalize and SHA-256 hash an email address before sending it to an ad platform."""
normalized = email.strip().lower()
return hashlib.sha256(normalized.encode("utf-8")).hexdigest()
print(hash_email(" [email protected] "))Common errors
- Collecting everything "just in case." This raises breach and compliance risk, and it buries the useful fields.
- Ignoring consent state downstream. A banner that records consent is useless if the export job does not read it.
- Counting list size as health. An email list full of inactive or bounced addresses lowers deliverability. Track active reach, not total records.
- Duplicate profiles. One person with three emails becomes three customers. Set matching rules, and merge records when you have strong evidence, such as a shared login.
- Mismatched formats. Hashing
[email protected]without normalizing produces a hash that matches nobody. - Assuming a cookie is an identity. Browsers expire and clear them, and people use several devices.
Measuring the health of the foundation
Track a few numbers over time rather than judging by feel.
| Metric | What it tells you |
|---|---|
| Known-ID rate | Share of sessions or orders tied to a customer ID |
| Consent rate by purpose | Share of visitors agreeing to analytics and marketing |
| Match rate on uploads | Share of your list the ad platform could match |
| Active reach | Contacts you emailed who opened or clicked within 90 days |
| Field completeness | Share of profiles with the fields your campaigns need |
If the known-ID rate is low, work on reasons to log in or identify. If the match rate is low, check normalization and the age of the data.
Exercise
A retailer sets a visitor ID cookie from JavaScript with a 2-year lifetime and treats it as a permanent customer ID. Name two reasons this will fail, and describe one change that gives a more durable identity.
Show answer
First, browsers such as Safari limit the lifetime of cookies written by JavaScript, so the cookie may expire in days instead of two years. Second, a cookie belongs to one browser on one device, so it is lost when the visitor clears cookies or switches devices, and it never connects to the person. A more durable identity comes from asking people to sign in or share an email at a moment of value, such as a receipt or saved cart, and storing a customer ID linked to the anonymous ID with consent.
Exercise
Your team uploads a customer list to an ad platform and sees a 12% match rate. Name two likely causes you can check in your own data before blaming the platform.
Show answer
The emails may not be normalized (extra spaces or mixed case) before hashing, so the hashes differ from the platform's. The list may also be old or full of addresses people no longer use, or may mostly contain emails that differ from those customers use to sign in to the platform. Check normalization first, then the age and quality of the records.