> Documentation index: https://metorial.com/llms.txt. Every page is available as Markdown by adding .md to its URL.

# Set up Google Analytics in Metorial for AI agents
URL: https://metorial.com/docs/integrations/google-analytics
Last updated: 2026-11-24

Share Google Analytics with your team in Claude, ChatGPT and Cursor through Metorial: OAuth or measurement protocol only sign-in, 13 tools (7 read-only).

---

To give your team Google Analytics in Claude, ChatGPT, Cursor and other AI clients, an admin shares the Google Analytics integration in a Metorial portal, and each person signs in to Google Analytics with their own account. Agents can query and retrieve analytics reports on user interactions, traffic, and engagement metrics across websites and apps. The integration has 13 tools, 7 read-only and 6 write, plus 2 triggers.

**What you will learn**

- How an admin shares Google Analytics in a portal and how each person connects
- The 5 OAuth scopes Google Analytics can request, and what each one allows
- How to keep the 7 read-only tools and reject the other 6

**Before you start**

- A [portal](https://metorial.com/docs/platform/workforce/portals) with at least one access group
- An account with Google Analytics for each person who connects
- For the CLI steps: the [Metorial CLI](https://metorial.com/docs/platform/cli), signed in to your portal

## Sign-in methods

| Method | Type | What a person provides |
| --- | --- | --- |
| **Measurement Protocol Only** | Custom credentials | `measurementId` and `apiSecret` |
| **OAuth 2.0** (default) | OAuth | Signs in to Google Analytics |

The portal and `metorial setup` use **OAuth 2.0** unless someone picks another method.

### Measurement Protocol Only

To connect, a person enters these values:

- `measurementId`: Measurement ID for web streams (e.g., "G-XXXXXXX").
- `apiSecret`: API secret for the Measurement Protocol. Generated in GA4 Admin > Data Streams.

### OAuth 2.0

People sign in to Google Analytics and approve the scopes you allow. The integration can request:

| Scope | Name | What it allows |
| --- | --- | --- |
| `https://www.googleapis.com/auth/analytics.readonly` | Analytics Read-Only | Read-only access to Google Analytics data and configuration. |
| `https://www.googleapis.com/auth/analytics.edit` | Analytics Edit | Edit access to Google Analytics configuration (also grants read access). |
| `https://www.googleapis.com/auth/analytics.manage.users` | Manage Users | Manage user permissions on Analytics accounts and properties. |
| `https://www.googleapis.com/auth/analytics.manage.users.readonly` | View User Permissions | View user permissions on Analytics accounts and properties. |
| `openid email profile` | User Profile | View basic profile information including email. |

### Setup settings

Whichever method you pick, setup also asks for:

- `propertyId` (optional): Optional GA4 property ID used by property-scoped tools when the tool input does not include propertyId. Accepts "123456789" or "properties/123456789".
- `measurementId` (optional): Optional GA4 web data stream Measurement ID used by Measurement Protocol tools when the tool input does not include measurementId.

## Use your own Google Analytics OAuth app

With your own OAuth app, people see your company's name on the Google Analytics consent screen, and the client ID and secret belong to you.

1. **Start the credentials in Metorial**

   In the dashboard, select **Settings**, then **Organization Settings**. Under **Integrations and MCP**, select **Provider Auth**, then **Create Auth Credentials**. Choose Google Analytics and copy the **Redirect URI**.

2. **Register the app**

   In the Google Cloud console, enable the API behind Google Analytics under **APIs & Services**, **Library**. Then go to **Google Auth platform**, **Clients**, click **Create Client**, choose **Web application**, and paste the redirect URI from Metorial under **Authorized redirect URIs**. Google shows the client secret only when you create the client.

   The [Google Workspace guide](https://metorial.com/docs/platform/integrations/google-workspace) covers the consent screen and the OAuth client in Google Cloud step by step.

3. **Finish in Metorial**

   Copy the app's client ID and client secret. Back in Metorial, enter a **Name**, the **Client ID** and the **Client Secret**, review **Scopes**, and select **Create**. Then pick these credentials for the Google Analytics integration.

## Admin: share Google Analytics in a portal

### In the dashboard

1. **Open Shared Resources**

   Open **Workforce**, choose the portal, and select **Shared Resources** under **Access**.

2. **Share a new integration**

   Select **Share a Resource**, then **New Integration**, and choose Google Analytics. Under **Auth Method**, keep **OAuth 2.0** or pick another. For how members connect, choose **Each person connects**, so everyone signs in to Google Analytics as themselves.

3. **Limit the tools**

   Under **Tool Filters**, set the write and destructive groups to **Reject** if agents should only read from Google Analytics.

4. **Choose who gets it**

   Add the access groups that should see Google Analytics. When a person asks for access from the portal, the request appears under **Access Requests**.

### With the CLI

The CLI cannot create the per-user Google Analytics integration. Once it exists, check which groups have it:

```bash
metorial-admin portals access list <portal-id> --type provider_template --search "google analytics"
```

## Employee: connect Google Analytics

### In the portal

1. **Open Google Analytics in the catalog**

   Sign in to your portal and open Google Analytics. The status reads **Available**.

2. **Authenticate**

   Under **Quick setup**, select **Authenticate**. A Google Analytics sign-in tab opens. Sign in and approve the permissions listed.

3. **Confirm**

   The status changes to **Configured**. If it later reads **Needs reconnect**, select **Reconnect** and sign in again.

### With the CLI

```bash
metorial catalog search "google analytics"
metorial setup <catalog-item-id>
```

`catalog search` prints the catalog item ID. `metorial setup` uses **OAuth 2.0**. To connect with **Measurement Protocol Only** instead, find its ID with `metorial catalog get <catalog-item-id>` and add `--auth-method <auth-method-id>`.

### Add it to your AI client

`metorial install` adds your Google Analytics connection to a local MCP client such as Claude Code, Cursor or Codex. `metorial list` prints the integration ID and `metorial client list` the client identifiers.

```bash
metorial list "google analytics"
metorial client list
metorial install <client-identifier> <integration-id>
```

For a client that takes a server URL, such as ChatGPT, `metorial install custom <integration-id>` creates an installation token and shows the endpoint details.

## Make it read-only

Open the integration's **Tool Filters** and set the write and destructive groups to **Reject**. Agents keep the 7 read-only tools, such as `run_report` and `get_metadata`, and lose the 6 write tools, such as `send_events` or `manage_audiences`.

Employees see the result on the integration's page in the portal under **Tool access**. For the full walkthrough, see [Tool permissions](https://metorial.com/docs/platform/guides/tool-permissions).

## Check it worked

```bash
metorial list "google analytics"
metorial tools <integration-id>
metorial call <integration-id> list_accounts_and_properties -d '{}'
```

`metorial tools` lists the 13 tools, minus any you rejected. `list_accounts_and_properties` takes no input. It lists Google Analytics accounts accessible to the authenticated user and their GA4 properties.

To see every input a tool takes, run `metorial schema <integration-id> <tool-key>`.

## Tools

### Read-only tools (7)

- `validate_events`: Validate event data against the GA4 Measurement Protocol without actually sending the events. Needs `clientId` and `events`.
- `list_accounts_and_properties`: List Google Analytics accounts accessible to the authenticated user and their GA4 properties.
- `run_report`: Query an analytics report from a GA4 property with configurable dimensions, metrics, date ranges, filters, and sorting. Needs `dateRanges` and `metrics`.
- `run_realtime_report`: Query real-time analytics data showing current activity on a GA4 property. Needs `metrics`.
- `audit_data_access`: Generate a data access report to audit who accessed your analytics data and when. Needs `startDate` and `endDate`.
- `run_funnel_report`: Generate a funnel report to visualize the steps users take to complete a task. Needs `steps`.
- `get_metadata`: Retrieve the available dimensions and metrics for a GA4 property.

### Write tools (6)

- `manage_key_events`: List, create, update, or delete key events (conversions) on a GA4 property. Needs `action`.
- `manage_audiences`: List, create, update, or archive audiences on a GA4 property. Needs `action`.
- `manage_custom_metrics`: List, create, update, or archive custom metrics on a GA4 property. Needs `action`.
- `send_events`: Send event data to Google Analytics 4 via the Measurement Protocol. Needs `clientId` and `events`.
- `manage_data_streams`: List, get, create, update, or delete data streams on a GA4 property. Needs `action`.
- `manage_custom_dimensions`: List, create, update, or archive custom dimensions on a GA4 property. Needs `action`.

## Triggers

Google Analytics has 2 triggers, which fire on events in Google Analytics:

- `inbound_webhook`
- `property_change`: Polls for configuration changes on a GA4 property, including updates to data streams, custom dimensions, custom metrics, key events, audiences, and other property settings.

## Next steps

- [Claude Code](https://metorial.com/docs/platform/clients/claude-code), [Cursor](https://metorial.com/docs/platform/clients/cursor), [Codex](https://metorial.com/docs/platform/clients/codex) and [ChatGPT](https://metorial.com/docs/platform/clients/chatgpt): connect each client to your portal and use Google Analytics there
- [Create custom OAuth credentials](https://metorial.com/docs/platform/integrations/create-custom-oauth-credentials): the Provider Auth screens in more detail
- [Tool permissions](https://metorial.com/docs/platform/guides/tool-permissions): tool filters and what employees see
- [Google Workspace guide](https://metorial.com/docs/platform/integrations/google-workspace): the consent screen and the OAuth client in Google Cloud
- [Google Analytics on metorial.com](https://metorial.com/integrations/google-analytics): the integration overview