Skip to main content

Set Up

Before You Begin

Make sure you have the following before starting:
  • Owner or IAM Admin access in your GCP project: You’ll need to create a service account, assign roles, and generate a key. The Owner, IAM Admin, or an equivalent role is required.
  • The dataset(s) you want to sync identified: Know which project, and optionally which datasets and tables, Conversion should be able to read from.
  • Your GCP project ID: Found in the Google Cloud Console next to the project name (e.g. my-company-prod). You’ll need it when connecting in Step 2.

Step 1: Set Up BigQuery Access

Conversion connects to BigQuery using a service account with a JSON key. In this step you’ll create a dedicated service account, grant it read access to your data, and (if needed) configure network access.

Create a Service Account

We recommend creating a dedicated service account for Conversion so its activity is easy to monitor and audit in isolation.
  1. In the Google Cloud Console, go to IAM & Admin → Service Accounts and create a new service account (e.g. conversion-sync).
  2. Grant it the BigQuery Job User and BigQuery User roles (project level).
  3. Open the service account, go to the Keys tab, and create a new JSON key. Save the downloaded file; you’ll upload it to Conversion in Step 2.

Grant Read Access to Your Data

The service account also needs BigQuery Data Viewer to read your tables. We recommend granting it at the dataset level so Conversion’s access is scoped to exactly the data you want it to see. New tables added to those datasets are picked up automatically. For each dataset you want Conversion to read, open BigQuery, find the dataset in the Explorer panel, click the three dots → Share, and add your service account email (e.g. conversion-sync@my-project.iam.gserviceaccount.com) with the BigQuery Data Viewer role.
Conversion only sees datasets you explicitly share. New datasets need to be shared with the service account before Conversion can read from them.
Granting Data Viewer at the project level
If your project doesn’t contain data Conversion shouldn’t see, you can grant BigQuery Data Viewer at the project level instead, either during service account creation or later in IAM & Admin → IAM. New datasets are then picked up automatically as you add them.

Allow IP Addresses

If your BigQuery project uses VPC Service Controls or restricts access by IP, allow connections from Conversion’s IP addresses:
Most BigQuery projects don’t restrict by IP. If you don’t use VPC Service Controls or perimeter rules, you can skip this step.

Step 2: Connect BigQuery to Conversion

  1. In Conversion, go to Settings → CRM and syncing → Connections.
  2. Click Add BigQuery connection.
  3. Fill in the connection details using the values from the earlier steps:
  4. Click Create connection.
Conversion will verify the connection. If successful, you’re ready to create syncs.

Create a Sync

After connecting, open your new BigQuery connection and go to the Syncs tab to create a sync. Read more about Setting Up a Sync.

Writing Queries for BigQuery

A few things to keep in mind before writing your first query:
  • Name your columns to match Conversion fields. Conversion maps results to fields by column name, so each column in your SELECT clause must match the field key in Conversion exactly (e.g. email, first_name, userId, event_id). Use AS to alias when the source name doesn’t match.
  • Always filter by last_sync_time so each run only processes changed rows. In BigQuery, wrap it with TIMESTAMP_SECONDS(); see Using last_sync_time for details.
  • Select only the columns you’ll actually use, as every column scanned costs money in BigQuery.
  • Schedule large syncs carefully. See Set the Schedule for how often to run queries that return millions of rows.

Contact Sync

Provide userId (preferred), email, or both; at least one is required so Conversion can match the contact.

Custom Objects (Without Relationships)

Alias your record’s unique identifier as object_id, and select the object’s own fields:

Custom Objects with Relationships

To link each record to a related record, alias a column to the key of a relationship field on the object. See Custom Objects with Relationships for the values each related object accepts.
In this example:
  • object_id identifies the Product record, and name, sku, category, and price are stored on it
  • owner is a relationship field on the Product object that points at Contacts, so each product links to the contact with that email address

Events

Events require a contact identifier (userId or email), event_name, and timestamp. event_id is optional but recommended. Conversion uses it to deduplicate events across runs, so it must be unique across all your event syncs; prefix it with the table name as shown.

BigQuery SQL Reference

Converting Timestamps

Conversion expects Unix timestamps for date/time fields. Use UNIX_SECONDS() to convert BigQuery TIMESTAMP or DATETIME values:

Using last_sync_time

See Incremental Syncing for how last_sync_time works. In BigQuery, convert it with TIMESTAMP_SECONDS() to compare against a TIMESTAMP column:
Or convert your column to Unix seconds and compare integers directly:
With a time buffer:

Handling NULLs

Use COALESCE or IFNULL to provide default values:

Casting Types

Use CAST to convert between types:

Querying Across Datasets

Use fully-qualified table names to join across datasets:

Troubleshooting

”Permission denied” errors

Ensure your service account has the required roles:
  • BigQuery Job User (project level)
  • BigQuery User (project level)
  • BigQuery Data Viewer (on each dataset you want to query)

“Could not connect” errors

Verify that:
  • You uploaded the service account’s JSON key file, unedited
  • Your project ID matches the project the service account belongs to
  • Conversion’s IP addresses are allowed if you use VPC Service Controls

Sync taking too long

  • Use partitioned tables and filter on the partition column for time-based data
For general tips, see Sync Taking Too Long.

Duplicate data appearing

If you’re using time-buffered queries (subtracting from last_sync_time to catch edge cases), Conversion handles duplicates automatically based on the unique key (userId or email for contacts, object_id for custom objects, event_id for events).

Frequently Asked Questions

The service account needs BigQuery Job User and BigQuery User at the project level, plus BigQuery Data Viewer on the datasets you want to sync. Conversion only reads data; it never writes to your BigQuery project.
BigQuery charges for the amount of data scanned by your queries. To minimize costs: select only the columns you need, filter with last_sync_time, and use partitioned tables where possible.
Use fully-qualified table names in your query:
Make sure BigQuery Data Viewer is granted on each dataset you reference.