Data Pipeline & Concepts
How CDP transforms raw events into unified customer profiles and actionable segments.
Overview
CDP's core data pipeline is a four-stage transformation process. Raw behavioral data lands in raw tables through the Public API, Airbyte (or another ELT tool), and File Import. It then passes through three progressive enrichment stages - column mapping and identity normalization, per-source identity clustering, and cross-source identity resolution - before yielding fully resolved Unified Profiles that power segmentation and campaign delivery.
Each stage runs as a Temporal workflow job, on a schedule or on demand (see each stage's Job type and schedule). Only one run per table or policy can be in progress; clicking again while it runs reports that a transform or build is already running. Watermarks record what each stage has already processed, so re-running a stage does not duplicate data. The one exception is Re-transform all: it re-inserts every row, and the new events collapse with the existing ones only where the mapping and dedup keys have not changed (see Changing the column mapping).
Stage 1 - Raw Data → Events
Stage 1 reads rows from the ClickHouse raw_data tables, maps them into events, normalizes
identity values and computes a dedup_key for each one. The result is the
cdp.events table - the canonical event store that all downstream stages read from.
Job type and schedule
transform-raw-to-events
How it runs: hourly for each table whose Auto Transform is on (off by default), or on demand from the event source's row menu on Ingestion > Events: Transform continues from the last watermark, and Re-transform all starts again from the beginning.
Entry points
- Public API:
POST /api/public/v1/raw-datawrites rows straight intoraw_data.<table>. The table must be open to the Public API (Ingestion > Data Sources, open the table, Add a source > Public API). - Airbyte (or another ELT tool): connectors sync tables into the raw warehouse, for ongoing syncs and historical backfills.
- File Import: CSV or JSONL files are loaded into
raw_data.<table>from the Data Imports screen (Ingestion > Data Sources, open the table, Add a source > File imports), either by Upload or from a watched S3 folder (Scheduled scan or Manual scan). File Import never starts the transform itself.
All three are picked up the same way: by the table's next transform - hourly when Auto Transform is on (it is off by default), or when someone clicks Transform. Rows written in the last 15 seconds wait for the following run, so an insert that is still committing is never skipped.
What happens in this stage
- Which tables run - A table is transformed only if it has an event source mapping with
at least one Identity column. It also needs cursor columns so CDP can read it
incrementally. Airbyte and Fivetran sync columns are detected automatically, and tables fed by the Public
API or File Import carry
_cdp_extracted_at/_cdp_raw_id. A table without them is skipped, and so is a mapped table that no longer exists. When each table runs is described under Job type and schedule above. - Column mapping - Only the columns checked in the mapping (Ingestion > Events, then Configure in the event source's row menu, or Add event source for a table that is not mapped yet) are written to the event, under their Target Name. Other raw columns are dropped. Empty and null values are skipped.
- Identity normalization - Every string value is trimmed of surrounding spaces. Values in
columns marked Identity are also normalized once, here, by the identity kind declared on
the column, before they are stored in
identity_info. See Identity normalization. - Deduplication - If the same row is transformed more than once (for example, a retried
API request or a re-imported file), every copy produces the same
dedup_key. The copies collapse into one event, the most recently written one, so profiles and counts see a single event. See Event Deduplication.
Identity normalization
Each column marked Identity in the column mapping declares an identity kind. Stage 1
normalizes the value by that kind before storing it in identity_info. Source and unified
profile matching compare these stored values as-is and never normalize again.
| Kind | Rule | Example |
|---|---|---|
| Trim + lowercase | John.Doe@Example.COM becomes john.doe@example.com |
|
| Phone | Trim + remove spaces - . ( ) | 090-123-4567 becomes 0901234567. No + or country code is
added, so 0901234567 and +84901234567 stay different. |
| Other | Trim only | - |
- A value that is empty after normalization, or the text
null/undefined, is left out. Normalization never repairs data ("N/A" stays "N/A"). - Event
propertieskeep the value as read (with only the surrounding-space trim), so user properties and campaign recipients are not affected. - One identity name has one kind across all mappings. Saving a different kind for the same name is
rejected (
IdentityKindConflict). - Choose the kind before the table's first transform. After that the editor locks it (see Changing the column mapping).
Output
Mapped events are written to the ClickHouse cdp.events table (a
ReplacingMergeTree); copies with the same dedup_key collapse into one event.
Key event fields
| Field | Type | Description |
|---|---|---|
event_source |
String | The Data Source name set on the column mapping (e.g. my_website). Fixed once the mapping is created. |
source_table |
String | The raw table the event came from. |
event_type |
String | The name of the action (e.g. page_view, purchase, sign_up). |
event_timestamp |
DateTime64 | When the event happened, read from the mapping's Event Timestamp column and stored in UTC. |
identity_info |
Object | Map of the columns marked Identity in the mapping, keyed by their Target Name (e.g. email, phone, user_id), with values normalized for each column's identity kind (see Identity normalization). Profiles are matched on these values. |
properties |
Object | Every checked column, under its Target Name, with surrounding spaces trimmed but otherwise as read. |
mapping_version_id |
Number | Version of the column mapping that produced the event. It increases when the mapped columns change; turning Auto Transform on or off, or saving without changes, does not change it. Use it to tell events from an earlier mapping apart. |
dedup_key |
String | Computed by CDP - you never send it. Has the form event_source|source_table|<hash>, where the hash covers the Dedup Key columns, or every mapped column if none is marked. See Event Deduplication. |
Changing the column mapping
Three things can be changed only until the table's first transform has run: which columns are Dedup Key, the Target Names of Identity columns, and their identity kinds. After that the column mapping editor locks them. To change them later, delete the event source and map the table again. Its events are deleted and the table is transformed from the beginning (see Deleting an event source).
Other mapping changes apply to events transformed from then on. Re-transform all re-inserts every row, and the new events collapse with existing ones only where the mapping and dedup keys have not changed. For example, with no Dedup Key marked, adding or removing a mapped column changes every key, so the re-transformed events sit alongside the old ones.
Deleting an event source
Delete in an event source's row menu (Ingestion > Events) runs the
delete-event-source-mapping job. It removes the mapping and permanently deletes every event it
produced from that table. Another table that uses the same Data Source name is not touched. Raw data stays,
and so does everything already built from those events: source profiles, unified profiles and their
events, user properties and segment membership. The table's watermark is cleared, so if you map the table
again it is transformed from the beginning.
The delete is refused while the data source is still used by an active unified merge policy or an active segment, which the dialog lists under "This event source cannot be deleted yet:". To remove the profiles built from a retired source as well, see Retire a Deprecated Data Source.
Stage 2 - Events → Source Profiles
Stage 2 reads events from cdp.events and builds per-source identity clusters called
Source Profiles. A Source Profile represents a unique user identity within a single data source.
Job type and schedule
build-source-profiles
How it runs: hourly at about five minutes past the hour (UTC) for every active source merge policy, or on demand with Build (the policy's row menu on Source Profiles, or its page), or with Save and build when creating a policy. A paused policy does not build.
How source merge policies work
A source merge policy belongs to one data source (Unification > Source Profiles > Create Merge Policy). It chooses from the identity keys that the data source's event mappings mark as Identity, and combines them into Merge Conditions. Each row is a condition set: keys in the same row must all match (AND), and separate rows are alternatives (OR). Two events that share every key of at least one row belong to the same Source Profile.
For example, if your website source merge policy includes two rows, email and
user_id, then two events - one with email: alice@example.com and another with
user_id: alice-12345, email: alice@example.com - would both be clustered into a single Source
Profile for Alice on the website source.
To change a policy, pause it first. Existing rows are locked. You can add new rows, and they are applied to existing profiles at the start of the next build. Profiles that were already merged are never split again. When a build finds that two existing profiles now match, the oldest one is kept and the other is merged into it.
Output
- ClickHouse
cdp.source_profiles- One row per source profile, scoped to the source merge policy that built it, with a stable UUIDsource_profile_id. - ClickHouse
cdp.source_profiles_identity_index- Maps each identity value to itssource_profile_id, so later batches and later builds attach new events to the right existing profile. - ClickHouse
cdp.source_profiles_events- Links each event to the source profile it belongs to; this is what the Events Timeline on a source profile's page shows.
The merge policies themselves are configuration and are stored in PostgreSQL.
Source Profiles are scoped to one source merge policy, and so to one data source. A user who appears on both your website and your mobile app will have two Source Profiles - one per source - until Stage 3 merges them into a single Unified Profile. If a data source has more than one source merge policy, each builds its own set of profiles.
Stage 3 - Source Profiles → Unified Profiles
Stage 3 is where cross-source identity resolution happens. It reads the source profiles built by the source merge policies that the unified policy lists, and merges those that refer to the same real-world customer into a single Unified Profile.
Job type and schedule
build-unified-profiles
How it runs: hourly at about ten minutes past the hour (UTC) for every active unified merge policy, or on demand with Build, on the policy page or in the Actions menu of the Unified Profiles dashboard. A paused (draft) policy does not build.
How unified merge policies work
A unified merge policy (Unification > Unified Profiles > Manage
Policies > New Policy) lists one source merge policy per data source under
Applicable source rules, plus its own Merge conditions. Two source
profiles are merged when they share every identity field inside at least one condition set (AND inside a
set, OR between sets). For instance: "merge website and mobile-app source profiles when they share the
same email". Identity fields are matched by name, so give the identity column the same Target
Name (e.g. email) in each source's mapping.
Each listed source merge policy is read incrementally on its own, and one added to the policy later is caught up from the beginning. While a source merge policy is paused it builds no new source profiles, so its new events reach unified profiles only after it is resumed. The profiles it already built stay merged.
CDP then runs the Union-Find algorithm across all Source Profiles within the scope of each policy. Any two Source Profiles that satisfy at least one of the policy's condition sets are merged into the same Unified Profile cluster. See the Identity Resolution section for more on the algorithm.
Active and inactive policies
Only one unified merge policy is meant to be active at a time (a newly saved policy also starts Active, so deactivate the other one), and the active policy's profiles are what the Unified Profiles screen shows. Manage Merge Policies has one Active slot ("1 of 1 allowed") and a list of Inactive policies. Activate (in Manage Merge Policies) moves an inactive policy into the slot and deactivates the previous active one. Deactivate (in Manage Merge Policies, or in the Actions menu of the dashboard card) stops the active policy's scheduled builds but keeps its profiles. The policy page offers the same two actions.
A policy can be edited or deleted only while it is inactive. Its existing condition sets stay locked, and new ones are applied to existing unified profiles on the next build.
The Engagement switch decides whether the policy's profiles feed user properties, segments, campaigns and recurring exports. It does not affect building the profiles or assigning their events. For step-by-step instructions, see the Admin Guide.
Output
- ClickHouse
cdp.unified_profiles- One row per unified profile, scoped to the unified merge policy that built it, with a stable UUIDunified_profile_id. Links from each unified profile to its source profiles are kept incdp.unified_profile_source_profiles. - ClickHouse
cdp.unified_profile_identity_index- Maps each identity value to itsunified_profile_id, so later builds attach new source profiles to the right existing unified profile.
After every successful build, the unified profile's events are copied into
cdp.unified_profile_events (see Downstream Activation).
Downstream Activation
After Unified Profiles are built, several additional workflows handle activation. These are not numbered pipeline stages - they are separate workflows that consume Unified Profiles and segment memberships. Assign Events starts automatically after each unified build. User properties and segments are recomputed about every minute for each unified merge policy with Engagement on. Campaigns and exports run on their own schedule or when started from their screen.
| Workflow | Job type | Purpose |
|---|---|---|
| Assign Events to Unified Profiles | assign-events-to-unified-profiles |
Starts automatically after every successful unified build. Copies each unified profile's events into cdp.unified_profile_events, which user properties and segments read. Runs for every unified merge policy whether or not Engagement is on, and does not start Compute User Properties or Compute Segments - they pick up the new events on their next cycle. |
| Compute User Properties | Schedule compute-user-properties-schedule-{ruleId} (not a job type) |
Derives computed attributes on Unified Profiles with one of two compute types: Raw value (the latest value of an event field) or Duration since (time elapsed since a datetime field). Managed in the User Properties section of the Unified Profiles dashboard or the unified policy page (Add User Property); there is no separate User Properties page. |
| Compute Segments | Schedule compute-segments-schedule-{ruleId} (not a job type) |
Evaluates segment condition rules against Unified Profiles and writes membership results to ClickHouse. |
| Execute Campaign Run | executeCampaignRunFlow (workflow, not a job type) |
Runs one send of a campaign: reads the segment's members (currently active unified profiles only), reads each recipient's address from the user property chosen in Send to, and sends through the campaign's channel (email, LINE or SMS). Values that are not a valid address for the channel (for SMS, an E.164 number such as +84901234567) are not sent, and the send log shows why. |
| Export Segment Profiles / Recurring Export | export-segment-profiles, recurring-export-run |
Export Segment Profiles writes one segment's members to a CSV you download from the segment's Recent Exports tab (kept 7 days). Recurring Export writes a policy's profiles or activity to a destination under Integrations > Data Destinations, and needs Engagement on. |
| Profile Count and Segment Size Snapshots | snapshot-profile-counts, snapshot-segment-sizes |
Hourly counts behind the Home and policy summary cards and a segment's Member count over time chart, so these numbers and charts are approximate. Profile counts include paused policies; segment sizes are taken only for active policies with Engagement on. |
Everything that hands profiles to a person, a count, a campaign or an export uses only currently active unified profiles; a profile that was merged into another is never sent twice.
Assign Events starts on its own after each unified build. Campaign runs start from the campaign's
schedule or send action, each as its own workflow rather than a controlWorkflow job type.
Exports start from their schedule or screen. Exports and maintenance jobs such as
get-segment-size and audit-log-cleanup run through
controlWorkflow's job types and can also be started from the Temporal CLI.
Compute User Properties and Compute Segments are not job types. Each unified merge policy with Engagement on gets two Temporal Schedules: user properties are computed at the start of every minute and segments 30 seconds later, so both recompute about every minute. Turning Engagement off removes both schedules. Each cycle only processes events that are new since the last cycle. Force Compute on a user property (Unified Profiles > User Properties section) or Force recompute on a segment marks that one item for a full recompute and fires the schedule. Editing a property's sources or filters, or a segment's definition, does the same. Force Compute is refused when Engagement is off.
Event Deduplication
CDP prevents duplicate events from polluting your analytics and profile data through a dedup_key-based mechanism.
How deduplication works
Every event written to cdp.events carries a dedup_key. The ClickHouse
ReplacingMergeTree engine uses this key to identify copies of the same event. Rows with the
same key collapse during background merges, and reads always return the most recent copy.
Which columns feed the hash
CDP always computes dedup_key during transform-raw-to-events. It is never a
literal pass-through of one column. The key has the form
event_source|source_table|<SHA-256 hash>. The hash covers the values of the columns you
mark as Dedup Key in the column mapping (after the surrounding-space trim), or every mapped
column if none is marked (see Stage 1 for where to edit the mapping). Identity
normalization does not change the hash, because it uses those trimmed values, not the normalized identity
values. Because event_source and source_table are part of the key, two event
sources or two tables never collide.
Dedup Keys are locked after the table's first transform - see Changing the column mapping.
For stronger deduplication guarantees - especially for events that may be retried by your application - mark a small, stable, business-meaningful column as the Dedup Key instead of relying on the fallback:
{
"source_table": "ecommerce_purchases",
"rows": [{
"user_id": "user123",
"order_id": "order987",
"amount": "49.99"
}]
}
If order_id is marked as the Dedup Key column for this table, even if your backend sends
this row twice due to a network timeout, both copies hash to the same dedup_key, so once the
transform has run CDP treats them as a single purchase event - the most recently written copy is the one
that is read.
Without a marked Dedup Key column, CDP hashes all mapped columns for the row - so a retried request whose properties differ even slightly (a refreshed timestamp, a recalculated total) will not be treated as a duplicate. Mark a stable Dedup Key column whenever your source system can produce retries.
At present, a Dedup Key column whose Target Name has been changed is left out of the hash, which can
make unrelated rows look like duplicates. If every Dedup Key column has been renamed, every row of the
table gets the same dedup_key and all of its events collapse into one. The
order_id example above is safe because its Target Name is unchanged.
Identity Resolution
Identity resolution is the process of determining which Source Profiles across different data sources
belong to the same real-world customer. CDP implements this using a classic
Union-Find (Disjoint Set Union) data structure with path compression and union by rank,
giving near-linear O(α(n)) time complexity even for tens of millions of profiles.
How Union-Find works in CDP
Each Source Profile starts as its own isolated cluster. When CDP finds two Source Profiles that share a
common identity value - say, both have email: alice@example.com - it calls union
to merge their clusters into one. After all overlaps are processed, each resulting cluster becomes one
unified profile. A cluster that contains an existing unified profile keeps that profile's ID; a brand-new
cluster gets a new ID.
Example: Cross-source identity merge
Consider a user named Alice who interacts with two different systems:
- Website source: Alice visits using her email
alice@example.com. CDP creates Source Profile SP-1 on the website source. - Mobile app source: Alice logs in with her email
alice@example.comand phone+81-90-1234-5678. CDP creates Source Profile SP-2 on the mobile app source.
During Stage 3, the unified merge policy lists both sources' merge policies and has a condition set on
email. CDP finds that SP-1 and SP-2 share the same email, so it calls
union(SP-1, SP-2). Both profiles are now part of the same cluster, and Alice gets a single
Unified Profile - UP-Alice - that aggregates identity from both sources.
If Alice later gives her phone number on a third source (e.g. an SMS opt-in form), that source profile also
joins UP-Alice. This happens only if the policy lists that source's merge policy under
Applicable source rules, has a condition set on phone, and the stored phone
values are equal. With the Phone kind, +81-90-1234-5678 is stored as
+819012345678. A form that collects 090-1234-5678 stores
09012345678, which does not match, because no country code is added.
Once assigned, a unified_profile_id stays the same across runs, and new events or source
profiles that join it do not change it. The one exception is a merge: when new data connects two existing
unified profiles, one of them is kept and the other becomes Inactive, pointing to the
survivor (Merged into on the profile page). Unified profile IDs belong to one unified
merge policy - a different policy builds its own profiles with their own IDs.
Configuring merge policies
Identity resolution is configured in two places. Source merge policies (Unification > Source Profiles > Create Merge Policy) decide which events form one source profile. The active unified merge policy (Unification > Unified Profiles > Manage Policies; see Active policy and drafts) decides which source profiles form one unified profile. In a unified policy you choose:
- Which sources take part - one source merge policy per data source under Applicable source rules
- Which identity fields must match - e.g.
emailbut notuser_id - How they combine - fields in one condition set must all match (AND); add another
condition set for an alternative way to match (OR), e.g. one set for
emailand one forphone
For most deployments, one active policy with a single condition set on email across all
sources is a good starting point. For step-by-step setup, see the
Admin Guide.