## Google Analytics integration

Google Analytics is Google's service for measuring traffic and engagement on websites and apps.

It can be connected to Agen.co two ways, matching the **Official** / **In-house** filter in the connector picker:

- **Official** — Agen.co connects through Google's own hosted Analytics MCP server, so your AI agents use the same reporting tools Google exposes to MCP clients.
- **In-house** — Agen.co wraps the Google Analytics APIs directly through its own integration layer, using a dedicated OAuth client you register in Google Cloud Console.


Pick **Official** if the built-in MCP tools cover what your agents need. Fall back to **In-house** if they need to list accounts and properties, or run pivot reports.

### Connect via the official MCP server

Preview
Google hosts this MCP server but hasn't published documentation for it yet. It works today, but Google can change its tools or behavior without notice.

Prerequisites
- A Google Cloud project where you can enable APIs, configure the Google Auth Platform, and create OAuth clients.
- For each user who connects, access to the Google Analytics 4 properties their agents report on.


#### Enable the API

In [Google Cloud Console](https://console.cloud.google.com/apis/library), select your project and enable the **Google Analytics Data API**.

#### Set up the OAuth consent screen

1. Go to **Google Auth Platform** → **Branding**. If you see **Google Auth Platform not configured yet**, click **Get Started**, enter an app name and a support email, and click **Next**.
2. Under **Audience**, select **Internal**. If you can't select it, select **External**. Finish the wizard and click **Create**.
3. If you selected **External**, open **Audience** and, under **Test users**, click **Add users** and add every Google account that will connect. Other accounts can't complete sign-in while the app is in testing.
4. Open **Data Access** → **Add or Remove Scopes**. Under **Manually add scopes**, paste the two scopes below, click **Add to Table**, click **Update**, then click **Save**.


| Scope | What it allows |
|  --- | --- |
| `https://www.googleapis.com/auth/analytics.readonly` | View the user's Google Analytics data |
| `https://www.googleapis.com/auth/analytics` | View and manage the user's Google Analytics data. Google's MCP server lists this scope, although its current tools only read data. |


#### Copy the callback URLs from Agen.co

1. In the Agen.co portal, go to **Connectors** → **My connectors** and click **Add connector**.
2. Search for `Google Analytics` and select it. At the top of the **Add Google Analytics** panel, keep **Official** selected.
3. Copy both read-only URLs at the bottom of the panel:
  - **Callback URL**: completes the initial OAuth handshake between Agen.co and your OAuth client.
  - **Gateway callback URL**: used by the Agen.co MCP gateway for per-user authorization at runtime.


Leave this panel open. You return to it after creating the OAuth client.

#### Create the OAuth client

1. In Google Cloud Console, make sure the same project is selected, then go to **Google Auth Platform** → **Clients** → **Create client**. The client must belong to the project where you enabled the **Google Analytics Data API**, because Google checks API enablement against the project that owns the credential.
2. Set **Application type** to **Web application** and enter a name (for example, `Agen.co Google Analytics MCP`). Leave **Use this client for an AI-powered agent** cleared.
3. Under **Authorized redirect URIs**, click **Add URI** and add **both** URLs you copied from Agen.co.
4. Click **Create**, then copy the **Client ID** and **Client Secret**. Google shows the secret only at creation, so copy it now. If you lose it, add a new secret from the client's detail page.


#### Connect Google Analytics in Agen.co

1. Return to the **Add Google Analytics** panel you left open and fill in the fields:


| Field | Required | Description |
|  --- | --- | --- |
| **Instance Slug** | Yes | Namespaces this instance. It prefixes each imported tool as `slug__tool`, so a second instance of the same connector needs its own slug. Use lowercase kebab-case, for example `google-analytics`. You can change it later from the connector's settings. |
| **Client ID** | Yes | The Client ID of the OAuth client you created. |
| **Client Secret** | Yes | The Client Secret of the OAuth client you created. |


1. Click **Connect**. You're redirected to Google to sign in and approve access.
2. Back in Agen.co, the panel shows **Select the tools to import from Google Analytics.** with a toggle for each tool, all on by default. Turn off any tool you don't want, then click **Add**. The connector is created and its tools imported only when you click **Add**, even if the Google sign-in page reported success.
3. After you create a [policy](/agen-for-work/policies/overview) for the tools, the first tool call a user makes returns a one-time authorization link instead of data. The user opens it and approves access with their own Google account. This per-user step uses the **Gateway callback URL** you registered, and each user does it once.


Once connected, Google Analytics appears under **My connectors** with tools spanning:

| Area | What it covers |
|  --- | --- |
| **Reports** | Running reports on a property's event data, including realtime reports |
| **Metadata** | Listing the dimensions and metrics a property supports, and checking which ones can be combined in one report |


Every tool works on one Google Analytics 4 property at a time, so agents need its numeric property ID, shown under **Admin** → **Property details** in Google Analytics. The Official MCP server can't list accounts or properties, so agents can't look up a property ID on their own. Use the **In-house** tab if your agents need to.

Enabling the Google Analytics connector isn't enough on its own. Tool calls remain denied until you create a [policy](/agen-for-work/policies/overview) that grants access to the specific tools you want to expose.

### Connect via the Google Analytics APIs

Integrating Google Analytics with Frontegg allows your application to run reports, retrieve analytics data, and manage Google Analytics 4 properties — all through Frontegg's integration layer using Google OAuth 2.0.

Prerequisites
- A Google account with access to [Google Cloud Console](https://console.cloud.google.com/)
- A Google Cloud project (you can create one during setup)


#### Enable the Google Analytics Data API

##### Step 1: Open the Google Analytics Data API in the API library

Go to the [Google Analytics Data API](https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com) page in the Google Cloud Console. Select your project from the top navigation, then click **Enable** if the API is not yet enabled. If you see **Manage** and **API Enabled**, the API is already active.

![Google Analytics Data API page in Google Cloud Console](/assets/google-analytics-1.22741699f3f5905d3ab3d6846471bc4e946c8efabf499fbcba1c8241ab7ce697.1ce25488.png)

#### Create an OAuth client

##### Step 2: Go to the Credentials page

In the left sidebar, navigate to **APIs & Services** → **Credentials**. Click **Create credentials**.

![Credentials page with Create credentials button highlighted](/assets/google-analytics-2.d1b106034522f0574d57681bcba2893aa2a4de99d6c2135f9416b20d261508d6.1ce25488.png)

##### Step 3: Select OAuth client ID

From the dropdown, select **OAuth client ID**.

![Create credentials dropdown with OAuth client ID highlighted](/assets/google-analytics-3.17f3e2d785b28573bad87c908874d34df752d06fc921edd2f4be907abc264e76.1ce25488.png)

##### Step 4: Configure the OAuth client

On the **Create OAuth client ID** page:

1. Set **Application type** to **Web application**.
2. Enter a name for the client (for example, `Frontegg Google Analytics Integration`).
3. Under **Authorized redirect URIs**, click **Add URI** and add the redirect URL shown in the Frontegg portal for this integration — copy it whole, including the path. See [How to get your Redirect URL](/agen-for-work/connectors/redirect-url).


The value has this shape, but take the real one from the portal rather than assembling it:

- `https://YOUR_MCP_GATEWAY_URL/integration-callback`


Click **Create**.

![OAuth client form with name and redirect URIs filled in](/assets/google-analytics-4.ac3b5b7dfc46b437f04634e35de6c1d4ec5b4ffaf459ba42f84946addfc39cd3.1ce25488.png)

##### Step 5: Copy your Client ID and Client Secret

After clicking **Create**, a dialog displays your **Client ID** and **Client Secret** — copy both values and store them securely.

Save your Client Secret now
The Client Secret is only shown once in this dialog. After you close it, you cannot retrieve it again — you can only create a new secret.

![OAuth client created dialog showing Client ID and blurred Client Secret](/assets/google-analytics-5.3020c34a72a032cb88de5a1b997e51d6d4eddfd7e72d348001d1216dda8480b3.1ce25488.png)

#### Copy your credentials

##### Step 6: View the new client in the credentials list

After closing the dialog, your new client appears at the top of the **OAuth 2.0 Client IDs** list on the Credentials page.

![Credentials page showing the new Frontegg Google Analytics Integration client](/assets/google-analytics-6.90cbcd0a1245f2c4d2e7f294b5612a14b5a82c33b870163b1798b7ce2c87a73c.1ce25488.png)

##### Step 7: View Client ID in the client detail page

Click the client name to open its detail page. You can view and copy the **Client ID** at any time from the **Additional information** section.

![OAuth client detail page showing Client ID in the Additional information section](/assets/google-analytics-7.4c81753b069bf43bc8e5ee836e4f38ea1940f9a33adfb242c9df85bb602510cf.1ce25488.png)

#### Configure the Frontegg portal

Once you have your **Client ID** and **Client Secret**, enter them in the Frontegg portal:

1. Open the **Frontegg portal** and navigate to [ENVIRONMENT] → Integrations → Google Analytics.
2. Enter the **Client ID** and **Client Secret** in the corresponding fields.
3. Select the required **scopes**:


| Scope | Description |
|  --- | --- |
| `https://www.googleapis.com/auth/analytics.readonly` | Read-only access to Google Analytics data |
| `https://www.googleapis.com/auth/analytics.edit` | Edit Google Analytics management entities |
| `https://www.googleapis.com/auth/analytics.manage.users` | Manage Google Analytics account users and permissions |
| `https://www.googleapis.com/auth/analytics.manage.users.readonly` | View Google Analytics account users and permissions |
| `https://www.googleapis.com/auth/analytics.provision` | Create new Google Analytics accounts |
| `https://www.googleapis.com/auth/analytics.user.deletion` | Manage user deletion requests |


1. Click **Save**.


Keep your credentials secure
Never share or commit your Client Secret to version control.

### Additional resources

- [Google Analytics Data API documentation](https://developers.google.com/analytics/devguides/reporting/data/v1)
- [Google Cloud Console](https://console.cloud.google.com/)
- [Setting up OAuth 2.0](https://developers.google.com/identity/protocols/oauth2/)
- [How to get your Redirect URL](/agen-for-work/connectors/redirect-url)