
## How BigQuery ingestion works

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`

{% figure %}
![BigQuery IAM permissions configuration](/images/statsig-warehouse-native/connecting-your-warehouse/bigquery/198107543-b3bcc19a-3231-4128-be42-a5dd52fb168a.png)
{% /figure %}

<br />

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.

   {% figure %}
   ![BigQuery dataset permissions setup](/images/integrations/data-imports/bigquery/175113611-90e618ad-f6e8-4005-933e-2a5660a14466.png)
   {% /figure %}

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.

{% figure %}
![Frame 4](/images/statsig-warehouse-native/connecting-your-warehouse/bigquery/187518062-7027f682-d1fd-445e-9947-897e44ea929e.png)
{% /figure %}

2. Copy the relevant Project ID from the modal.

{% figure %}
![Frame 5](/images/statsig-warehouse-native/connecting-your-warehouse/bigquery/187517901-9e7fd237-8325-4254-a1bd-c75f0ea08497.png)
{% /figure %}
