# BigQuery

> For AI agents: a documentation index is available at [/llms.txt](/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

## How BigQuery ingestion works

Statsig ingests your event and metric data from Google BigQuery so it flows into your Statsig metrics and experiments. To set up a connection with BigQuery, you need to:

- Grant permissions to a Statsig-owned service account
- Provide your BigQuery Project ID

Enable the BigQuery source under Metrics > Ingestion > Add Source.

## Grant permissions to Statsig's service account

Grant the following permissions from your Google Cloud console to allow Statsig to access your BigQuery data.

1. In your BigQuery's [IAM & Admin settings](https://console.cloud.google.com/iam-admin/), add the Statsig service account you copied in the Statsig Console as a new principal for your project, and give it the following roles:

   - `BigQuery User`

![BigQuery IAM permissions configuration](https://docs.statsig.com/images/statsig-warehouse-native/connecting-your-warehouse/bigquery/198107543-b3bcc19a-3231-4128-be42-a5dd52fb168a.png)

2. Navigate to your [BigQuery SQL Workspace](https://console.cloud.google.com/bigquery), choose the dataset, click on "+ Sharing" -> "Permissions" -> "Add Principal" to give the same Statsig service account "BigQuery Data Viewer" role on the dataset.

   ![BigQuery dataset permissions setup](https://docs.statsig.com/images/integrations/data-imports/bigquery/175113611-90e618ad-f6e8-4005-933e-2a5660a14466.png)

The service account now has the required permissions to export data from this dataset.

## Find your BigQuery Project ID

1. Click on your Project Dropdown inside your Cloud Console.

![Frame 4](https://docs.statsig.com/images/statsig-warehouse-native/connecting-your-warehouse/bigquery/187518062-7027f682-d1fd-445e-9947-897e44ea929e.png)

2. Copy the relevant Project ID from the modal.

![Frame 5](https://docs.statsig.com/images/statsig-warehouse-native/connecting-your-warehouse/bigquery/187517901-9e7fd237-8325-4254-a1bd-c75f0ea08497.png)
