> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcemedium.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Analytics 4 (GA4) - Integration Instructions

> Connect Google Analytics 4 to SourceMedium with OAuth or a BigQuery export.

GA4 web and app analytics come into SourceMedium for traffic and attribution. The OAuth connection reads the Data API. The BigQuery export reads the property's event tables, for funnel views and multi-touch attribution.

## How to connect

<Info>
  You connect data sources yourself in SourceMedium. Sign in to your [SourceMedium account](https://urchin.sourcemedium.com), open your store, then in the **Data sources** section click **Connect data source** and choose the platform. You need an **Editor** or **Admin** role on the store. If you have view-only access, ask an admin or editor on your team to connect it.

  Once it is connected, [what happens next](/docs/data-inputs/platform-integration-instructions/after-you-connect) covers first-sync timing and what each connection status means.
</Info>

Most stores only need the OAuth connection. Connect the BigQuery export when you want those event tables, or when the property already exports them.

### Option 1: Connect with OAuth

<Steps>
  <Step title="Start the GA4 connection">
    Find **GA4** in the connector picker and click **Connect**. The **Connect GA4** page opens on the **Authorize** step.
  </Step>

  <Step title="Authorize with GA4">
    Click **Authorize with GA4**. SourceMedium sends you to Google in the same tab to approve the **read-only** Analytics access it requests, then brings you straight back. Sign in with an account that has access to your GA4 property. SourceMedium reads Analytics data only; it does not change anything in GA4.
  </Step>

  <Step title="Select the GA4 property">
    Back in SourceMedium, pick the GA4 property you want to sync, then save.
  </Step>

  <Step title="Confirm it is connected">
    The flow finishes on **Done** and the connection shows **Connected**. SourceMedium begins syncing sessions, events, transactions, and item-level ecommerce from the GA4 Data API.
  </Step>
</Steps>

### Option 2: Connect the BigQuery export

Google allows one BigQuery link on a property.

#### SourceMedium creates the link

<Steps>
  <Step title="Start GA4 BigQuery Export">
    Find **GA4 BigQuery Export** in the connector picker and click **Connect**.
  </Step>

  <Step title="Authorize">
    Click **Authorize with GA4 BigQuery Export**. Sign in with a Google account that can edit the property. SourceMedium creates the link, then brings you back to pick the property.
  </Step>

  <Step title="Save the property">
    Pick the GA4 property and click **Save property**. Google writes the export to a dataset named `analytics_` plus that property id.
  </Step>
</Steps>

If the picker says the property is already linked to a BigQuery project, leave that link where it is and record the dataset below. Moving the link into SourceMedium's project can pause the export while Google switches.

#### The export already exists

Connect GA4 and select the property first (Option 1). The dataset Google created is named `analytics_` plus that property id.

<Steps>
  <Step title="Copy the dataset path">
    Open [BigQuery](https://console.cloud.google.com/bigquery). In **Explorer**, expand your project, open **Datasets**, and click that dataset.

    At the top of the dataset, click the copy button next to the path. It looks like `my-project.analytics_123456789`. Copy the path, not a table.

    <Frame caption="Copy button next to the dataset path">
      <img src="https://mintcdn.com/sourcemedium/X8ga0sCe8NL2VDqY/images/article-imgs/ga4-integration/copy-dataset-path.png?fit=max&auto=format&n=X8ga0sCe8NL2VDqY&q=85&s=719cc83fccdd138d9e3320defa2d4014" alt="Dataset analytics_123456789 selected in BigQuery, with the copy button next to my-project.analytics_123456789." width="960" height="340" data-path="images/article-imgs/ga4-integration/copy-dataset-path.png" />
    </Frame>
  </Step>

  <Step title="Paste it on the GA4 connection">
    In SourceMedium, open the **GA4** connection. Under **BigQuery export**, paste the path into **BigQuery dataset path**.
  </Step>

  <Step title="Save after the check">
    SourceMedium checks that it can read the dataset. **Save dataset** turns on when the check passes. Click it, then confirm **Read this BigQuery export**.

    An empty dataset is fine. The first daily table usually shows up the next day. If the tables are not daily event tables (`events_YYYYMMDD`), the check says this is not a GA4 export.
  </Step>
</Steps>

<Warning>
  Sessions and transactions can change on the next warehouse refresh. Reporting switches from the Data API to this export.
</Warning>

If SourceMedium cannot read the dataset, grant the SourceMedium runtime account **BigQuery Data Viewer** on the project and try again.

To change the path later, open **GA4 BigQuery Export** for this store. The field is under **Export**.

**Disconnect BigQuery export** stops SourceMedium from reading the dataset. Google keeps exporting until you remove the link in Google Analytics.

## What data syncs

The OAuth path uses the GA4 Data API. It lands:

| Report | Grain | What it is for |
| - | - | - |
| Sessions | Date + source / medium / campaign / channel group | Traffic mix |
| Events | Date + event name | Event counts |
| Transactions | Transaction ID + attribution | Purchase attribution, including session source, medium, and campaign, the literal `utm_content`, `utm_term`, and `utm_id` values, and the landing page with its query string |
| Items | Item / product | Enhanced ecommerce. On by default |

Dates use the GA4 property timezone, not UTC. GA4 can emit more than one purchase event for the same transaction, so dedupe by transaction ID before summing revenue.

Once a BigQuery export is connected, reports use those event tables instead of the Data API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.