Docs/GA4 + BigQuery Setup

GA4 + BigQuery Setup

Google Analytics 4 (GA4) tracks when someone views your affiliate's link and then installs your app. BigQuery stores those events so PartnerDock can query them and match installs to affiliates. This guide walks you through the full setup.

20–30 min · One-time setup

How attribution works

When an affiliate shares their link, the URL contains an mref parameter (e.g. apps.shopify.com/your-app?mref=their-code). When a merchant clicks that link and views your app listing, GA4 captures that page view including themref value. When the merchant then installs your app, Shopify fires ashopify_app_install event into GA4 — and GA4 links it to the same user who viewed the listing, so PartnerDock can match install → affiliate.

GA4 exports these events to BigQuery daily. PartnerDock queries BigQuery using a shared service account and surfaces the results on your dashboard and in the Analytics section.

No code required. All tracking runs through Shopify's Measurement Protocol — Shopify fires the install event on your behalf once you enter your GA4 credentials in the Shopify Partner portal.

Part 1 — Set up Google Analytics 4

If you already have a GA4 property for your Shopify app, skip to Part 2.

Create a GA4 account and property

1
Go to analytics.google.com and sign in with your Google account.
2
Click the gear icon (Admin) in the bottom-left corner.
3
Click Create → Account. Enter an account name (e.g. your company name). Click Next.
4
Enter a Property name (e.g. your app name), set your timezone and currency. Click Next.
5
Fill in your business category and size, click Next. Select your business objective, click Create.
6
Accept the terms of service. You'll be taken to the property setup screen.

Add a data stream

7
Click Add stream and select Web.
8
In the Website URL field, enter the full URL of your Shopify app listing — including the slug:

Website URL example

https://apps.shopify.com/your-app-slug

This must match your actual app listing URL exactly.

9
Give the stream a name (e.g. your app name). Click Create and continue.
10
You'll see the stream details. Copy the Measurement ID — it starts with G-.

Measurement ID

G-XXXXXXXXXX

You will paste this into the Shopify Partner portal in Part 2.

Get the Measurement Protocol API Secret

11
On the same stream details page, scroll down and click Measurement Protocol API secrets.
12
Accept the terms if prompted, then click Create.
13
Give it a nickname (e.g. Shopify App Listing) and click Create.
14
Copy the Secret value shown on screen. It won't be displayed again.

API Secret

abcXYZ123…

You will paste this into the Shopify Partner portal in Part 2.

Part 2 — Add tracking to Shopify Partner portal

This tells Shopify to send install events to your GA4 property when merchants install your app.

1
Go to partners.shopify.com and sign in.
2
Click Apps in the left sidebar, then click your app.
3
Go to Distribution → Manage listing, then click Edit on your primary listing.
4
Scroll down to the Tracking information section.
5
Paste your Measurement ID (from Part 1, Step 10) into the Google Analytics Measurement ID field.
6
Paste your API Secret (from Part 1, Step 14) into the Measurement Protocol API secret field.
7
Click Save.
After saving, Shopify will start sending shopify_app_install events to GA4 whenever a merchant installs your app from the App Store. Events appear in GA4 within a few minutes. BigQuery export starts the following day.

Part 3 — Create a Google Cloud project

BigQuery lives inside Google Cloud. You need a project to hold your GA4 export data.

1
Go to console.cloud.google.com and sign in with the same Google account you used for GA4.
2
Click the project selector in the top bar (it may say Select a project or show an existing project name).
3
Click New project.
4
Enter a project name. Use something memorable:

Project name example

my-app-analytics

Lowercase letters, numbers, and hyphens only.

5
Click Create. Wait a few seconds for the project to provision.
6
Once created, make sure the new project is selected in the top bar. Copy the Project ID shown below the project name — you'll need it in Part 6.

Project ID example

my-app-analytics-428710

This is different from the project name. It's shown in the Cloud Console header and on the project dashboard.

7
Attach a billing account (required). In the Cloud Console left menu go to BillingLink a billing account and add one with a valid card. If BigQuery shows a Sandbox banner, this is the step that clears it.
This is the #1 place founders get stuck. BigQuery starts in Sandbox mode (no billing), and while GA4 export is free, the daily export will not run and no dataset will be created until a billing account with a valid payment method is attached to the project. Enabling billing does not mean you'll be charged — GA4 export data for a typical Shopify app is well under 1 GB, inside the free tier (first 10 GB storage + 1 TB queries/month). You're enabling billing so the export can run, not because it costs anything.

This tells GA4 to export all events to BigQuery daily.

2
Click Admin (gear icon, bottom-left), then under the Property column click BigQuery links.
3
Click Link.
4
Click Choose a BigQuery project. Select the project you created in Part 3.
5
Under Data location, leave it as default (or choose the region closest to you).
6
Under Configure data streams and events, enable your web data stream. Turn on Include advertising identifiers if prompted.
7
Set the export frequency to Daily. Click Submit.
8
The link will appear in the BigQuery links table. Status will show Active.
Important: the dataset isn't created instantly. GA4 exports to BigQuery as a once-a-day batch, so the analytics_<property-id> dataset only appears at the first daily export — up to ~24 hours after linking (it runs early afternoon in your GA4 reporting timezone). If a day has passed and there's still no dataset, the cause is almost always BigQuery still being in Sandbox — go back and attach a billing account (Part 3, step 7).

Part 5 — Grant PartnerDock access to BigQuery

PartnerDock uses a shared service account to query your BigQuery data. You grant it read-only access — it cannot modify your data.

1
In Google Cloud Console, make sure your project is selected in the top bar.
2
Click the hamburger menu (☰)IAM & AdminIAM.
3
Click Grant access (the blue button at the top of the principals list).
4
In the New principals field, paste the PartnerDock service account email exactly:

PartnerDock service account

partnerdock-bq@partnerdock.iam.gserviceaccount.com

Copy this exactly — any typo means PartnerDock won't be able to query your data.

5
Click Select a role. Search for and add BigQuery Data Viewer.
6
Click Add another role. Search for and add BigQuery Job User.
7
Click Save.
Why two roles? BigQuery Data Viewer lets PartnerDock read your event tables. BigQuery Job User lets it run query jobs. Both are required — granting only one will result in errors.

Part 6 — Enter your IDs in PartnerDock

Now connect everything inside PartnerDock.

Project ID vs Dataset ID — they're different things. Google Cloud makes this confusing. The full BigQuery address is written as project_id.dataset_id.
  • Project ID is your whole Google Cloud project — e.g. my-app-analytics-428710.
  • Dataset ID is the folder inside that project holding your GA4 data — e.g. analytics_123456789.
So for my-app-analytics-428710.analytics_123456789, the Dataset ID is just the part after the dot: analytics_123456789.
You do not create the dataset manually. When you linked GA4 to BigQuery in Part 4, Google automatically creates a dataset named analytics_<your-property-id>at the first daily export (~24 hours). If you don't see it after a day, the usual cause is that the project is still in Sandbox — attach a billing account (Part 3, step 7) and it'll appear at the next export. Only create a dataset by hand if you're not using the GA4 export (advanced setups).

How to find your Dataset ID in the Cloud Console

1
Go to console.cloud.google.com/bigquery and make sure your project is selected in the top bar.
2
In the Explorer panel on the left, click the arrow next to your project name to expand it.
3
The names listed underneath your project are your datasets. The one starting withanalytics_ is the GA4 export — that name is your Dataset ID.

Dataset ID example

analytics_123456789

The number after analytics_ is your GA4 Property ID.

Organisation-level: GCP Project ID

1
In PartnerDock, go to Settings → GA4 + BigQuery.
2
In the GCP Project ID field, enter your Google Cloud Project ID (from Part 3, Step 6).

GCP Project ID

my-app-analytics-428710

Find it in the Google Cloud Console header dropdown, or at console.cloud.google.com/home/dashboard.

3
Click Fetch datasets. PartnerDock will connect to your BigQuery project and list all available datasets.
4
In the Default BigQuery Dataset ID dropdown, select the dataset that starts with analytics_ followed by a number.

Dataset ID example

analytics_123456789

This number is your GA4 Property ID. If you have multiple datasets, pick the one matching the app you're setting up.

5
Click Save organisation settings.

Per-app: GA4 Property ID

6
Scroll down to your app in the Per-app settings section.
7
In the BigQuery Dataset ID field for your app, enter the same analytics_XXXXXXXXX value. (This can be left blank if it matches the default above.)
8
In the GA4 Property ID field, enter just the number from your GA4 property — found in GA4 Admin → Property → Property details.

GA4 Property ID

123456789

This is a 9-digit number shown in GA4 Admin → Property details. Do not include the G- prefix.

9
Click Save for the app.

Part 7 — Verify the connection

1
After saving, PartnerDock runs a set of checks. You'll see status indicators for:
GA4 events detectedBigQuery is reachable and your dataset has data
shopify_app_install eventsInstall events are being exported to BigQuery
mref parameter presentAffiliate referral codes are being captured on listing page views
utm_content presentAlternative attribution parameter is present
Shop identifiers presentShopify store URLs are attached to install events
Checks are red on day one. BigQuery takes up to 24 hours to create the first partition after you link GA4. Come back the next day and re-check. If checks are still red after 48 hours, email support@getpartnerdock.com.
2
Once all checks are green, PartnerDock will start attributing installs to affiliates in the Referrals section of your dashboard. New installs appear within 24 hours of the install happening (next BigQuery export cycle).