> 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

In this article we will show you how to store your Segment data in BiqQuery. To do this, you need to follow a few steps:

1. Enable BigQuery for your Google Cloud project
2. Create a GCP service account for Segment to connect with
3. Create a warehouse in the Segment app

#### Create a Project and Enable BigQuery

1. Go to Google [Cloud Platform](https://console.cloud.google.com)

* If you don’t have a project already, [create one](https://support.google.com/cloud/answer/6251787?hl=en\&ref_topic=6158848)
* If you have an existing project, you will need to [enable the BigQuery API](https://cloud.google.com/bigquery/quickstart-web-ui). Once you’ve done so, you should see BigQuery in the “Resources” section of Cloud Platform

{% 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 %}

3. 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)

#### Create a Service Account for Segment

Refer to [Google Cloud’s documentation about service accounts](https://cloud.google.com/iam/docs/creating-managing-service-accounts) for more information.

1. 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)
2. Click Create Service Account along the top
3. Enter a name for the service account (for example: “segment-warehouses”) and click Create
4. When assigning permissions, make sure to grant 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)

5. [Create a JSON key](https://cloud.google.com/iam/docs/creating-managing-service-account-keys). The contents of the downloaded file will be used to create your warehouse 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)

#### Create the Warehouse in Segment

1. In Segment, go to Workspace > Add destination > Search for “BigQuery” - it can be found in 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)
2. Select BigQuery
3. Add a name for the destination
4. 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)
5. Copy the contents of the credentials (the JSON key) into the Credentials field *Optional*: Enter a [region code](https://cloud.google.com/compute/docs/regions-zones) in the Location field (the default will be “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)
6. Click **Connect**
7. If Segment can connect with the provided Project ID and Credentials, a warehouse will be created and your first sync should begin shortly

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)
