Skip to content

Step 1: Prepare Your BigQuery Data

Organize your BigQuery tables to match the Composable Parent Segment data model: one Customers table and one or more Behaviors tables. Tables should reside within a BigQuery dataset in your GCP project.

Customers Table

The Customers table is the single source of all profile data and attributes. Every column you want to use for segmentation must be in this table.

RequirementDescription
Unique key columnA column with unique values per customer (e.g., cdp_customer_id)
No duplicate keysEach row must represent a unique customer profile
All attributesAll customer properties for segmentation must be columns in this table

Example Customers Table

cdp_customer_idemailfirst_namelast_namecitycountrygendermembership_tierltvaovnext_best_channelnext_best_offer
001alice@example.comAliceSmithTokyoJPFGold5000120emaildiscount_20
002bob@example.comBobJonesOsakaJPMSilver250080pushfree_shipping

Behaviors Tables

Each Behaviors table represents a specific type of customer activity. You can define multiple Behaviors tables (e.g., page views, purchases, email clicks).

RequirementDescription
Key columnMust contain a column with the same customer identifier used in the Customers table (e.g., cdp_customer_id) as join key to link back to the Customers table
Time columnTimestamp column for the event (e.g., time) -- must be Unix timestamp (INT64) or TIMESTAMP type
Event columnsAdditional columns describing the event details

Example Behaviors Table

cdp_customer_idtimetd_urltd_title
0012025-11-20 10:30:00https://example.com/productsProducts Page
0012025-11-20 11:00:00https://example.com/cartShopping Cart
0022025-11-20 12:15:00https://example.com/saleSale Page

BigQuery IAM Permissions

Ensure the service account you plan to use has the required IAM roles. You can grant these via the Google Cloud Console (IAM & Admin > IAM > Grant Access) or via gcloud:

# Grant job execution permission at project level
gcloud projects add-iam-policy-binding <project_id> \
  --member="serviceAccount:<sa_name>@<project_id>.iam.gserviceaccount.com" \
  --role="roles/bigquery.jobUser"

# OR: Grant read+write access at dataset level (required for activations)
bq add-iam-policy-binding \
  --member="serviceAccount:<sa_name>@<project_id>.iam.gserviceaccount.com" \
  --role="roles/bigquery.dataEditor" \
  <project_id>:<dataset_name>
RoleScopeWhen to use
roles/bigquery.jobUserProject levelAlways required -- allows Treasure AI to run query jobs
roles/bigquery.dataEditorDataset levelZero-copy queries + activations (read + write)

Also ensure the BigQuery API is enabled in your GCP project: APIs & Services > Enabled APIs > BigQuery API.