# BigQuery Setup

To connect your BigQuery data warehouse to Weavely, follow these steps. This integration enables seamless data transfer and reporting capabilities directly within your Weavely account.

{% embed url="<https://www.loom.com/share/eb4ed46fe6b24e24a8e67483fe19079c?sid=e1a21917-62a5-428f-818a-93c1404b8c57>" %}

## Access Data Warehouse Settings

1. Go to your **Agency Dashboard** in Weavely.
2. Navigate to **Settings** and select **Data Warehouse**.
3. If BigQuery is not yet connected, Weavely will prompt you to enter your **GCP Project ID**.

## Locate Your GCP Project ID

1. Open the **Google Cloud Console** and navigate to your **BigQuery page**.
2. To find your Project ID, click the drop-down menu at the top of the GCP page. Here, you’ll see a list of your available projects, with the Project ID listed next to each.
   * You can also find the Project ID in the URL bar or on your GCP dashboard under **Project ID**.
3. Copy your Project ID.

{% hint style="warning" %}
Make sure that your GCP project has a [billing account linked](https://cloud.google.com/billing/docs/how-to/modify-project)! If not, even if BigQuery is connected to Weavely no data will be able to flow through.
{% endhint %}

## Enter Project ID and Select Region in Weavely

1. Go back to Weavely and paste the **Project ID** into the designated field.
2. Choose a region for your BigQuery datasets. The most common choices are **US** or **EU**.
   * **Note**: It’s advisable to keep all datasets in the same location, as combining datasets from different locations may be challenging.

## Grant Access

1. Click **Grant Access** to begin the authorization process.
2. Complete the Google login flow, verifying the permissions required for Weavely to access your BigQuery project.

## Wait for Configuration Completion

1. Weavely will set up the necessary configurations, including creating service accounts to facilitate data access.
2. Once completed, a success message will appear, confirming that BigQuery is now connected.

Your BigQuery data warehouse is now successfully connected to Weavely, and you’re ready to start importing data for reporting and analysis.

***

## Troubleshooting

If you encounter errors while connecting BigQuery to Weavely, they are typically caused by a small number of common configuration issues.

<details>

<summary><strong>Missing permissions</strong>: you don’t have rights to change IAM settings. Ask a project Owner to give you either Owner or Project IAM Admin access.</summary>

#### **1. You don’t have the required IAM permissions**

To make IAM changes in a GCP project, you *must* have the **Project IAM Admin** role (or **Owner**). If you don’t, follow these steps to get the right access:

1. **Ask an existing Project Owner** to grant you the **Project IAM Admin** role (`roles/resourcemanager.projectIamAdmin`) — this role specifically contains the permissions needed to view and update IAM policies.&#x20;
2. They should go to **Google Cloud Console → IAM & Admin → IAM**.
3. Select your user, click **Edit principal**, then **Add another role**.
4. Choose **Project IAM Admin** from the role dropdown and click **Save**.
5. Once added, the changes may take a couple of minutes (sometimes up to \~7 minutes) to propagate.&#x20;

After this, you'll have all permissions required to adjust IAM settings for the project.

You can read more about IAM permissions [here](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access).&#x20;

</details>

<details>

<summary><strong>No active billing account:</strong> BigQuery won’t activate unless your GCP project has a billing account linked, even during trials.</summary>

BigQuery (and most GCP services) won’t work unless your project is linked to an active Cloud Billing account. To fix this, follow these steps:

1. Go to **Google Cloud Console → Billing**.
2. If you don’t have a billing account yet, create one by adding a valid payment method (credit card, debit card, or bank account).
3. Once your billing account exists, open **Billing → Account Management** and check that the account is active with no payment issues.
4. Link your project to the billing account by going to **Billing → Manage Billing for Project**, then selecting the correct billing account.
5. If the billing account is suspended or closed, resolve any payment problems and reopen it before linking it to your project.

After the project is linked to an active billing account, BigQuery and other services will become available. You can read more about connecting a billing account [here](https://docs.cloud.google.com/billing/docs/how-to/manage-billing-account).&#x20;

{% hint style="success" %}
You don’t need to worry about unexpected charges when connecting BigQuery. BigQuery gives you **5TB of free query processing per month**, and storage costs only a few pennies. In the first couple of weeks (and especially while you’re testing) your costs should be effectively **zero**. If you stay on the **Weavely free tier**, the amount of data we send to your project stays well within the free limits, so you shouldn’t see any charges unless you're doing very heavy data processing. GCP just requires a billing account to be attached, even if your usage remains free.
{% endhint %}

</details>

<details>

<summary><strong>Domain restrictions:</strong> your organization may block sharing access with external domains. Follow the steps below to update those settings.</summary>

If you are receiving an error stating that the domain is not allowed by organization policy when trying to add a new user to IAM, you need to modify the **Domain Restricted Sharing** constraint.

You must have the **Organization Policy Administrator** role to make these changes.

**Option 1: Via Google Cloud Console (Recommended)**

1. Navigate to the [**Organization Policies**](https://console.cloud.google.com/iam-admin/orgpolicies) page in the Google Cloud Console.
2. **Important:** At the very top of the page, ensure you have selected the correct **Project** (to fix it for one project) or your **Organization** (to fix it globally).
3. In the Filter bar, search for: `Domain restricted sharing` *(Technical ID: `constraints/iam.allowedPolicyMemberDomains`)*
4. Click the policy name to open it, then click **Manage Policy**.
5. Select **Override parent's policy**.
6. Under **Rules**:
   * If there is an existing rule, click the trash can icon 🗑️ to remove it.
   * Click **Add a Rule**.
   * Set **Policy values** to **Allow All**.
7. Click **Set Policy**.

You should now be able to add users from any domain immediately.

**Option 2: Via Cloud Shell (CLI)**

If you have the `gcloud` CLI installed or use Cloud Shell, you can run the following command.

*Replace `YOUR_PROJECT_ID` with the actual Project ID where you are adding the user.*

```bash
gcloud org-policies set-policy --project=YOUR_PROJECT_ID \
  <(echo "name: projects/YOUR_PROJECT_ID/policies/iam.allowedPolicyMemberDomains
  spec:
    rules:
    - allowAll: true")
```

You can read more about domain restricted sharing [here](https://docs.cloud.google.com/resource-manager/docs/organization-policy/domain-restricted-sharing).&#x20;

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://weavely.gitbook.io/weavely-help-centre/connecting-bigquery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
