> For the complete documentation index, see [llms.txt](https://help.littledata.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.littledata.io/integrations/shopify-to-segment/send-data-from-segment-to-bigquery.md).

# Send data from Segment to BigQuery

This guide shows you how to store your Segment data in BigQuery. You'll set up a Google Cloud project, create a service account for Segment, and add BigQuery as a warehouse destination in Segment.

### Set up your Google Cloud project

{% stepper %}
{% step %}
Go to Google [Cloud Console](https://console.cloud.google.com/)
{% endstep %}

{% step %}
Create or configure your project.

* If you do not have a project, [create one](https://support.google.com/cloud/answer/6251787?hl=en\&ref_topic=6158848).
* If you have an existing project, [enable the BigQuery API](https://cloud.google.com/bigquery/quickstart-web-ui). BigQuery then appears in Cloud Platform’s **Resources** section.

{% hint style="info" %}
Make sure [billing is enabled](https://support.google.com/cloud/answer/6293499#enable-billing) on your project, or Segment will not be able to write into the cluster.
{% endhint %}
{% endstep %}

{% step %}
Copy the project ID. You will need it when you create a warehouse source in the Segment app.

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-40a4e3fed3c918afa770aed540f701da435c14f5%2Fscreenshot-2022-03-11-at-15.30.55.png?alt=media)
{% endstep %}
{% endstepper %}

### Create a service account for Segment

Segment uses a service account to write to BigQuery. See [Google Cloud’s documentation about service accounts](https://cloud.google.com/iam/docs/creating-managing-service-accounts) for more information.

{% stepper %}
{% step %}
From the Navigation panel on the left, go to **IAM & admin** > **Service accounts**.

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-fffc03ebb3e5210af622a5e3a87f996225cfe8c9%2Fscreenshot-2022-03-11-at-13.39.23.png?alt=media)
{% endstep %}

{% step %}
Click **Create Service Account**.
{% endstep %}

{% step %}
Enter a name for the service account, such as `segment-warehouses`, then click **Create**.
{% endstep %}

{% step %}
Assign the following roles:

* **BigQuery Data Owner**
* **BigQuery Job User**

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-5b323f83927b3deb6337ca17804f71b261505722%2Fscreenshot-2022-03-11-at-13.51.35.png?alt=media)

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-f0397cd2ec5c40817a6c7253c2026517b0698e3c%2Fscreenshot-2022-03-11-at-13.51.56.png?alt=media)
{% endstep %}

{% step %}
[Create a JSON key](https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Use the downloaded file’s contents in the next section.

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-7618a31be4b8b1f542b8de755711f2102bc19627%2Fscreenshot-2022-03-11-at-13.52.31.png?alt=media)
{% endstep %}
{% endstepper %}

### Add BigQuery as a warehouse in Segment

{% stepper %}
{% step %}
In Segment, go to **Workspace** > **Add destination**. Search for “BigQuery” under **Storage Destinations**.

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-19fb63da340bba6f398e837719418ff3365805ec%2Fscreenshot-2022-03-16-at-11.07.01.png?alt=media)
{% endstep %}

{% step %}
Select **BigQuery**.
{% endstep %}

{% step %}
Add a name for the destination.
{% endstep %}

{% step %}
Enter your project ID in the **Project** field.

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-448725192ae4810aad31d0b04587e2db5787ad99%2Fscreenshot-2022-03-16-at-11.11.09.png?alt=media)
{% endstep %}

{% step %}
Paste the JSON key into the **Credentials** field. Optionally, enter a [region code](https://cloud.google.com/compute/docs/regions-zones) in **Location**. The default is “US”.

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-662fa6143a92f94ab2ee0ef8863a376e8d6479c7%2Fscreenshot-2022-03-16-at-11.11.56.png?alt=media)
{% endstep %}

{% step %}
Click **Connect**.
{% endstep %}

{% step %}
Segment creates the warehouse after validating the project ID and credentials. Your first sync begins shortly after.
{% endstep %}
{% endstepper %}

Once the data will reach BigQuery, under your project, you will be able to see a new dataset with multiple tables and partitioned tables (special tables that are divided into segments that make it easier to manage and query your data).

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-a5a1dc98ca052116ee962674f4e823a20846af12%2Fscreenshot-2022-03-17-at-11.50.44.png?alt=media)
