# BigQuery integration

{% hint style="info" %}
**Please Note!**\
This is a comprehensive guide to setting up a Google Analytics account for your Shopify app listing and connecting it with Shoffi. If you’ve already set up Google Analytics for the app listing, proceed to the next step [#set-up-bigquery](#set-up-bigquery "mention").&#x20;
{% endhint %}

### Jump to

[#set-up-google-analytics](#set-up-google-analytics "mention")

[#connect-your-shopify-app-listing](#connect-your-shopify-app-listing "mention")

[#set-up-bigquery](#set-up-bigquery "mention")

## Set up Google Analytics

### 1. Set Up or Access Your Google Analytics Account

Visit [analytics.google.com](https://analytics.google.com) and sign in using your Google account credentials.

### 2. Navigate to the Admin Section

<div align="left"><figure><img src="/files/eFIPjdHx58VoKyMcV6PI" alt=""><figcaption></figcaption></figure></div>

Click on the gear (cog) icon located at the bottom left to access the Admin panel.

### 3. Initialize a New Account

If you are starting a fresh account, you can skip the initial setup. Otherwise, click the **Create** button and select **Account**.

<div align="left"><figure><img src="/files/8kUhv7PZldHY3B206SGC" alt=""><figcaption></figcaption></figure></div>

### 4. Provide an Account Name

Enter a suitable name for your account and then click **Next** to proceed.

<figure><img src="/files/HOOa8wM4X9YM2XEmfBUP" alt=""><figcaption></figcaption></figure>

### 5. Specify Property Details

Input a name for your property, choose the appropriate timezone and currency, and then click **Next**.

<figure><img src="/files/ECCcvAtTaZownTxwHsdr" alt=""><figcaption></figcaption></figure>

### 6. Enter Business Information

Fill in your business category and size, then click **Next** to continue.

### 7. Define Business Objectives

Select the relevant business objectives that align with your goals and click **Create**.

### 8. Accept Google Analytics Terms of Service

Choose the terms applicable to your region. When ready, accept the terms by clicking the **I Accept** button.

### 9. Set Up Data Collection

Add a data stream to collect data from Shopify for your application. Select the **Web** platform.

<figure><img src="/files/KyOTNeLrakXRqP9KtxGj" alt=""><figcaption></figcaption></figure>

### 10. Create a Web Stream

Enter your Shopify app’s URL, assign a name to the stream, and then click **Create and continue**.

{% hint style="warning" %}
**Please Notice!**\
Make sure the "Website URL" is the full URL of your app listing, including the slug (ex. <https://apps.shopify.com/my-demo-app>).
{% endhint %}

<figure><img src="/files/F8byeuZGdQvu2eylHlo6" alt=""><figcaption></figcaption></figure>

### 11. Record the Measurement ID

Take note of the Measurement ID as this will be necessary for integration with Shopify via the Partner portal.

<figure><img src="/files/EXxvRoqngHp9Mk7d0eHa" alt=""><figcaption></figcaption></figure>

### 12. Obtain the API Secret

On the same page, retrieve the API Secret by clicking on **Measurement Protocol API secret**.

<figure><img src="/files/QeERN91quz0KrZXsi0nO" alt=""><figcaption></figcaption></figure>

### 13. Generate the API Secret

You may need to review and accept the terms first.

Next, click the **Create** button.

Assign a nickname to the API Key, such as “Shopify App Listing,” and click **Create**.

Ensure you save the secret value (API Secret) for future use.

<figure><img src="/files/uhMJOBBA44pNTS9jRs68" alt=""><figcaption></figcaption></figure>

## Connect your Shopify app listing

### 1. Access the Shopify Portal

Log in at [partners.shopify.com](https://partners.shopify.com).

### 2. Select Your App

From the left-hand menu, choose **Apps**.

Select your specific app.

<div align="left"><figure><img src="/files/U3ZeGCbHwCsRm06aprn2" alt=""><figcaption></figcaption></figure></div>

Navigate to **Distribution** in the left menu.

<div align="left"><figure><img src="/files/nMBxloTavUoRLqeGUpZQ" alt=""><figcaption></figcaption></figure></div>

Click on the **Manage Listing** button.

<div align="left"><figure><img src="/files/oZwbzNistRzOybaRez5M" alt=""><figcaption></figcaption></figure></div>

Now click Edit on your primary listing.

<figure><img src="/files/qZIzBxHX7SuopZtqGoII" alt=""><figcaption></figcaption></figure>

### 3. Input Google Analytics Details

Scroll to the **Tracking Information** section and enter your Measurement ID and API Secret in the designated fields. After entering the information, click **Save**.

<figure><img src="/files/6cg68FaCftlTa5AUE2Vl" alt=""><figcaption></figcaption></figure>

## Set up BigQuery

### &#x20;**1. Provision BigQuery in Google Cloud**

**1. Sign in**

Visit the [**Google Cloud Console**](https://console.cloud.google.com/) and log in (or create a new account).

**2. Create a GCP project**

1\. Click **Select a project ▸ New Project** at the top.\
2\. Name it something memorable (e.g., `myapp-shoffi-integration`).

<figure><img src="/files/H9MNd5oH9shfmzRTxHiF" alt=""><figcaption></figcaption></figure>

### **2. Link GA4 to BigQuery**

1. In **GA4 ▸ Admin**, choose **BigQuery links**.

<figure><img src="/files/cuuqtvEJcLD99OXldqst" alt=""><figcaption></figcaption></figure>

2. Click "Link" and select the project you just created.
3. Enable **Daily** export.

<figure><img src="/files/ltvLvC7m88lJHTQAK3Qo" alt=""><figcaption></figcaption></figure>

4. Confirm the link appears in the BigQuery links table.

### **3. Authorise Shoffi to read your dataset**

1. Open [**IAM & Admin**](https://console.cloud.google.com/iam-admin/iam) and ensure the correct project is selected (on the top left dropdown).
2. Click **Grant access**.
3. Enter the Shoffi's service-account e-mail:\
   `shoffi-bigquery-master@shoffi.iam.gserviceaccount.com`
4. Assign these roles, under the "BigQuery" section:

   * **BigQuery Data Viewer** – permits read access.
   * **BigQuery Job User** – permits query jobs.

   <figure><img src="/files/bjKo3h6pytzpdH8XBKE9" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Tip:**\
If you hit a policy error, the simplest fix is:\
• Go to [**Cloud Organization Policies**](https://console.cloud.google.com/iam-admin/orgpolicies/list).\
• Locate **constraints/iam.allowedPolicyMemberDomains**.\
• Click **Manage Policy ▸ Add Rule ▸ Allow All**.
{% endhint %}

### 4. Plug BigQuery into Shoffi

<figure><img src="/files/9fOfZJdDxo5Fm3r37hOC" alt=""><figcaption></figcaption></figure>

**1. Enter the GA Property ID**

Go to Admin > Property > Property details and copy the property ID from the top right.

<figure><img src="/files/m5xjsUwVMeRuPb5576LM" alt=""><figcaption></figcaption></figure>

**2. Enter the BigQuery Project ID**

Visible at the top of the Google Cloud dashboard or in the "BigQuery links" page in Google Analytics.

<figure><img src="/files/tPe3NlknNdLhplkzUJFl" alt=""><figcaption></figcaption></figure>

**3. Submit the details.**

{% hint style="warning" %}
*Dataset missing?* Google can take **up to 24 hours** to create the first partition. Come back later and pick it up once it appears.
{% endhint %}


---

# 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://docs.shoffi.app/for-app-owners/bigquery-integration.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.
