{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Step 1: Prepare Your BigQuery Data","description":"Organize your BigQuery tables for Composable Audience Studio, including Customers table, Behaviors tables, and IAM permissions.","siteUrl":"https://docs.treasure.ai","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"step-1-prepare-your-bigquery-data","__idx":0},"children":["Step 1: Prepare Your BigQuery Data"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Organize your BigQuery tables to match the Composable Parent Segment data model: ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["one Customers table and one or more Behaviors tables."]}," Tables should reside within a BigQuery dataset in your GCP project."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"customers-table","__idx":1},"children":["Customers Table"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Customers table is the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["single source of all profile data and attributes."]}," Every column you want to use for segmentation ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["must be in this table."]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Requirement"},"children":["Requirement"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unique key column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A column with ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["unique values per customer"]}," (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cdp_customer_id"]},")"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["No duplicate keys"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Each row must represent a unique customer profile"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["All attributes"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["All customer properties for segmentation must be columns in this table"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-customers-table","__idx":2},"children":["Example Customers Table"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"cdp_customer_id"},"children":["cdp_customer_id"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"email"},"children":["email"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"first_name"},"children":["first_name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"last_name"},"children":["last_name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"city"},"children":["city"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"country"},"children":["country"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"gender"},"children":["gender"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"membership_tier"},"children":["membership_tier"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"ltv"},"children":["ltv"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"aov"},"children":["aov"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"next_best_channel"},"children":["next_best_channel"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"next_best_offer"},"children":["next_best_offer"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["001"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["alice@example.com"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Alice"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Smith"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tokyo"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["JP"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["F"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Gold"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5000"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["120"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["email"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["discount_20"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["002"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["bob@example.com"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Bob"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Jones"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Osaka"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["JP"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["M"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Silver"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2500"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["80"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["push"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["free_shipping"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"behaviors-tables","__idx":3},"children":["Behaviors Tables"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each Behaviors table represents a specific type of customer activity. You can define multiple Behaviors tables (e.g., page views, purchases, email clicks)."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Requirement"},"children":["Requirement"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Key column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Must contain a column with the same customer identifier used in the Customers table (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cdp_customer_id"]},") as join key to link back to the Customers table"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Time column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Timestamp column for the event (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["time"]},") -- must be Unix timestamp (INT64) or TIMESTAMP type"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Event columns"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Additional columns describing the event details"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-behaviors-table","__idx":4},"children":["Example Behaviors Table"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"cdp_customer_id"},"children":["cdp_customer_id"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"time"},"children":["time"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"td_url"},"children":["td_url"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"td_title"},"children":["td_title"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["001"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2025-11-20 10:30:00"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://example.com/products"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Products Page"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["001"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2025-11-20 11:00:00"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://example.com/cart"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopping Cart"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["002"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2025-11-20 12:15:00"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://example.com/sale"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Sale Page"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"bigquery-iam-permissions","__idx":5},"children":["BigQuery IAM Permissions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ensure the service account you plan to use has the required IAM roles. You can grant these via the Google Cloud Console (",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["IAM & Admin"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["IAM"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Grant Access"]},") or via ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["gcloud"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# Grant job execution permission at project level\ngcloud projects add-iam-policy-binding <project_id> \\\n  --member=\"serviceAccount:<sa_name>@<project_id>.iam.gserviceaccount.com\" \\\n  --role=\"roles/bigquery.jobUser\"\n\n# OR: Grant read+write access at dataset level (required for activations)\nbq add-iam-policy-binding \\\n  --member=\"serviceAccount:<sa_name>@<project_id>.iam.gserviceaccount.com\" \\\n  --role=\"roles/bigquery.dataEditor\" \\\n  <project_id>:<dataset_name>\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Role"},"children":["Role"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Scope"},"children":["Scope"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"When to use"},"children":["When to use"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles/bigquery.jobUser"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Project level"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Always required -- allows Treasure AI to run query jobs"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles/bigquery.dataEditor"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Dataset level"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Zero-copy queries + activations (read + write)"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Also ensure the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["BigQuery API"]}," is enabled in your GCP project: ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["APIs & Services"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Enabled APIs"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["BigQuery API"]},"."]}]},"headings":[{"value":"Step 1: Prepare Your BigQuery Data","id":"step-1-prepare-your-bigquery-data","depth":1},{"value":"Customers Table","id":"customers-table","depth":2},{"value":"Example Customers Table","id":"example-customers-table","depth":3},{"value":"Behaviors Tables","id":"behaviors-tables","depth":2},{"value":"Example Behaviors Table","id":"example-behaviors-table","depth":3},{"value":"BigQuery IAM Permissions","id":"bigquery-iam-permissions","depth":2}],"frontmatter":{"seo":{"title":"Step 1: Prepare Your BigQuery Data","description":"Organize your BigQuery tables for Composable Audience Studio, including Customers table, Behaviors tables, and IAM permissions."}},"lastModified":"2026-06-09T02:16:04.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/composable-cdp/bigquery/prepare-bigquery-data","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}