This guide walks you through connecting Google BigQuery to Conversion and setting up your first sync.Documentation Index
Fetch the complete documentation index at: https://docs.conversion.ai/llms.txt
Use this file to discover all available pages before exploring further.
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.- In the Google Cloud Console, go to IAM & Admin → Service Accounts and create a new service account (e.g.
conversion-sync). - Grant it the BigQuery Job User and BigQuery User roles.
- Open the service account, go to the Keys tab, and create a new JSON key. Save the downloaded file; you’ll paste its contents into 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 — and so 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.
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 Conversion’s IP Addresses
If your BigQuery project uses VPC Service Controls or restricts access by IP, allow connections from Conversion’s IP addresses:| Region | IP Addresses |
|---|---|
| US | 35.239.90.161, 35.188.167.166, 34.56.101.43, 34.122.97.230, 34.29.176.66, 35.226.154.44 |
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
- In Conversion, go to Settings → CRM & Syncing → Connections.
- Click Add BigQuery connection.
- Fill in the connection details using the values from the earlier steps:
Field What to enter Where it came from Name A friendly label, e.g. Production BigQueryFree-text, just for your reference in Conversion Project ID Your GCP project ID, e.g. my-company-prodFound in the Google Cloud Console next to the project name Service Account Credentials The full contents of your JSON key file Generated in Step 1 - Click Connect
Step 3: 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
SELECTclause must match the field key in Conversion exactly (e.g.email,first_name,userId,eventId). UseASto alias when the source name doesn’t match. - Always filter by
last_sync_timeso each run only processes changed rows. In BigQuery, wrap it withTIMESTAMP_SECONDS(); see Using last_sync_time for details. - Select only the columns you’ll actually use, as every column scanned costs money in BigQuery.
Contact Sync
ProvideuserId (preferred), email, or both; at least one is required so Conversion can match the contact.
Custom Objects (Without Relationships)
To sync objects without relating them to contacts, omit theemail column:
Custom Objects with Relationships
To sync custom objects and their relationships to contacts in a single query, include the contact’semail and use JSON_OBJECT for relationship-specific fields:
- Object fields (
id,name,sku,category,price) are stored on the Product object emailidentifies which contact to create a relationship withrelationshipFieldscontains fields stored on the relationship itself (this contact’s role, quantity, etc.)
If multiple rows share the same object
id but have different email values, Conversion creates one object with multiple relationships, one per contact.Events
Events require a contact identifier (userId or email), event_name, and timestamp. eventId is optional but recommended. Conversion uses it to deduplicate events across runs.
BigQuery SQL Reference
Converting Timestamps
Conversion expects Unix timestamps for date/time fields. UseUNIX_SECONDS() to convert BigQuery TIMESTAMP or DATETIME values:
Using last_sync_time
{{last_sync_time}} is a Unix timestamp in seconds (an integer). Conversion substitutes the integer value directly into your query at run time; do not wrap it in quotes.
Use it in a WHERE clause to limit each run to rows that have changed since the last successful sync. On the first sync the value is 0, so every row matches.
To compare it against a BigQuery TIMESTAMP column, convert the integer to a timestamp with TIMESTAMP_SECONDS():
updated_at might be slightly stale, subtract seconds from the integer before converting:
Building Nested Objects with JSON_OBJECT
BigQuery doesn’t support dot notation for creating nested objects. UseJSON_OBJECT to build nested structures like relationshipFields:
Handling NULLs
UseCOALESCE or IFNULL to provide default values:
Casting Types
UseCAST 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:- The service account JSON key was pasted in full, including the surrounding
{and} - 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
- Ensure you’re filtering by
last_sync_timeto reduce rows - Select only the columns you need
- Use partitioned tables and filter on the partition column for time-based data
- Reduce sync frequency for large datasets
Duplicate data appearing
If you’re using time-buffered queries (subtracting fromlast_sync_time to catch edge cases), Conversion handles duplicates automatically based on the unique key (userId or email for contacts, id for objects, eventId for events).
Frequently Asked Questions
What BigQuery permissions does Conversion need?
What BigQuery permissions does Conversion need?
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.
How much does this cost in BigQuery?
How much does this cost in BigQuery?
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.How do I sync from multiple datasets?
How do I sync from multiple datasets?
Use fully-qualified table names in your query:Make sure BigQuery Data Viewer is granted on each dataset you reference.
What if a contact doesn't exist yet?
What if a contact doesn't exist yet?
If you sync a custom object with a
userId or email that doesn’t exist in Conversion, we create the contact automatically with just that identifier. You can enrich that contact’s profile through a separate contacts sync.