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

# Google Analytics Integration

> Connect Gradial to Google Analytics to surface content performance data directly inside your workflows.

Connecting Google Analytics to Gradial gives your agents access to real-time and historical performance data — page views, sessions, bounce rates, conversions — so they can make content decisions grounded in how your audience actually behaves.

<Info>
  Before connecting, confirm with your legal, privacy, or data governance team that your organization has approval to share analytics data with Gradial. This includes ensuring the connection complies with any applicable data processing agreements, privacy policies, or regional data regulations.
</Info>

***

## What You Can Do

| Capability                 | Description                                                                  |
| -------------------------- | ---------------------------------------------------------------------------- |
| Performance-informed edits | Surface underperforming pages and trigger content update tasks automatically |
| Traffic data in context    | Reference GA metrics when drafting or updating content                       |
| Optimization workflows     | Route low-performing URLs into content review queues                         |
| Audience signals           | Use GA audience and behavior data to guide personalization decisions         |

***

## Prerequisites

Before connecting Google Analytics to Gradial, make sure you have:

* A **Google Analytics 4 (GA4)** property (Universal Analytics is not supported)
* A **Google Cloud project** with the **Google Analytics Data API** enabled
* A **service account** with Viewer-level access to the GA4 property, and a JSON key generated for it
* A Gradial organization **Administrator** role to complete setup

***

## How to Connect

<Steps>
  <Step title="Enable the Google Analytics Data API">
    In your Google Cloud project, go to **APIs & Services → Library**, search for **Google Analytics Data API**, and enable it.
  </Step>

  <Step title="Create a service account and JSON key">
    1. In your Google Cloud project, go to **IAM & Admin → Service Accounts** and click **Create Service Account**.
    2. Give it a descriptive name (e.g., `gradial-analytics`).
    3. Under **Keys**, select **Add Key → Create new key (JSON)**. Download the JSON file and keep it open — you will paste its contents into Gradial in Step 4.
  </Step>

  <Step title="Grant the service account access to your GA4 property">
    1. In [Google Analytics](https://analytics.google.com/), open **Admin** for the property you want to connect.
    2. Under **Property Access Management**, add the service account email with the **Viewer** role.
  </Step>

  <Step title="Add the integration in Gradial">
    1. In Gradial, go to **Settings → Integrations**.
    2. Find **Google Analytics** and click **+ Add**.
    3. Enter an **Integration Name** (e.g., `My Google Analytics Connection`).
    4. The **Google Analytics API URL** is pre-filled as `https://analyticsdata.googleapis.com` — leave this as-is.
    5. Under **Authentication Type**, **OAuth 2.0 JWT Bearer** is selected by default.
    6. In the **Service Account JSON Key** field, paste the full contents of the JSON key file downloaded in Step 2.
    7. The **Scopes** field defaults to `https://www.googleapis.com/auth/analytics.readonly` and **Token Endpoint** defaults to `https://oauth2.googleapis.com/token` — leave both as-is unless directed otherwise.
    8. Optionally, enter a **Default GA4 Property ID**. This is the numeric Property ID from **Google Analytics → Admin → Property Settings**. When provided, Gradial uses it automatically when no property is specified in a prompt.
    9. Click **Validate Connection** to confirm the credentials work, then click **Validate & Save**.
  </Step>

  <Step title="Assign to an Environment">
    1. Go to **Settings → Environments** and select the Environment where analytics data should be available.
    2. Add the Google Analytics integration to that Environment.
    3. Repeat for any additional Environments.
  </Step>
</Steps>

***

## Field Reference

| Field                        | Description                                                                            |
| ---------------------------- | -------------------------------------------------------------------------------------- |
| **Integration Name**         | A display name for this connection in Gradial (e.g., `My Google Analytics Connection`) |
| **Google Analytics API URL** | Pre-filled as `https://analyticsdata.googleapis.com` — do not change                   |
| **Authentication Type**      | Fixed to **OAuth 2.0 JWT Bearer**                                                      |
| **Service Account JSON Key** | Paste the full JSON key content from Google Cloud                                      |
| **Scopes**                   | Defaults to `https://www.googleapis.com/auth/analytics.readonly`                       |
| **Token Endpoint**           | Defaults to `https://oauth2.googleapis.com/token` (from the JSON key's `token_uri`)    |
| **Default GA4 Property ID**  | Optional. The numeric GA4 Property ID used when no property is specified in a prompt   |

***

## Troubleshooting

**Validation fails with "Permission denied"**
Confirm the service account has been added as a Viewer in **Google Analytics → Admin → Property Access Management** and that the Analytics Data API is enabled in your Cloud project.

**GA4 Property ID not found**
Your Property ID is a numeric string found under **Admin → Property Settings → Property ID**. It is not the same as the Measurement ID (which starts with `G-`).

**Integration not available in a Workspace**
Assign the integration to the correct Environment under **Settings → Environments**.

***

## Support

Contact your Gradial onboarding lead or email [support@gradial.com](mailto:support@gradial.com) for help with setup.
