> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/google-analytics.md).

# Google Analytics

Google Analytics is a web analytics platform that tracks and reports website and app traffic, user behavior, and conversion metrics.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector        | Authentication |
| ---------------- | -------------- |
| Google Analytics | OAuth sign-in  |

#### Google Analytics

Connect to Google Analytics to access your website and app analytics data, including traffic metrics, user behavior, and custom reports.

**Set up in Google Analytics**

1. Sign in to the Google account that has access to your Google Analytics (GA4) properties.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **Google Analytics**.
2. Select **Connect**, sign in to the provider account, and review the requested access. Complete authorization to return to StackAI.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

StackAI obtains the OAuth credentials during sign-in. You do not need to paste an access token or refresh token.

**Provider documentation:** [Setup reference](https://support.google.com/analytics/answer/9304153).

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **Google Analytics** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Run Report

Run a report to get analytics data from a GA4 property

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field       | Type            | Required | Description                                                                                                 |
| ----------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| Property ID | select (string) | Yes      | The GA4 property ID. Select from the dropdown or enter manually. Options load from the selected connection. |
| Metrics     | string          | Yes      | Comma-separated metric names (e.g. activeUsers, sessions, screenPageViews).                                 |
| Dimensions  | string          | No       | Comma-separated dimension names (e.g. date, country, pagePath). Default: .                                  |
| Start Date  | string          | Yes      | Start date in YYYY-MM-DD format, or relative like '7daysAgo', '30daysAgo'.                                  |
| End Date    | string          | Yes      | End date in YYYY-MM-DD format, or relative like 'today', 'yesterday'.                                       |
| Row Limit   | integer         | No       | Maximum number of rows to return (default 500, max 250000). Default: 500.                                   |

**Outputs**

| Field             | Type   | Description                                            |
| ----------------- | ------ | ------------------------------------------------------ |
| Result Message    | string | A message indicating the result of the operation.      |
| Report Rows       | array  | The report data rows with dimension and metric values. |
| Row Count         | number | Total number of rows returned.                         |
| Metric Headers    | array  | The metric column names in the report.                 |
| Dimension Headers | array  | The dimension column names in the report.              |

#### Run Realtime Report

Get realtime analytics data showing current active users and activity

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field       | Type            | Required | Description                                                                                                 |
| ----------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| Property ID | select (string) | Yes      | The GA4 property ID. Select from the dropdown or enter manually. Options load from the selected connection. |
| Metrics     | string          | Yes      | Comma-separated realtime metric names (e.g. activeUsers, screenPageViews).                                  |
| Dimensions  | string          | No       | Comma-separated realtime dimension names (e.g. country, unifiedScreenName). Default: .                      |
| Row Limit   | integer         | No       | Maximum number of rows to return (default 500, max 250000). Default: 500.                                   |

**Outputs**

| Field             | Type   | Description                                                     |
| ----------------- | ------ | --------------------------------------------------------------- |
| Result Message    | string | A message indicating the result of the operation.               |
| Report Rows       | array  | The realtime report data rows with dimension and metric values. |
| Row Count         | number | Total number of rows returned.                                  |
| Metric Headers    | array  | The metric column names in the report.                          |
| Dimension Headers | array  | The dimension column names in the report.                       |

#### Get Metadata

List all available metrics and dimensions for a GA4 property

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field       | Type            | Required | Description                                                                                                 |
| ----------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| Property ID | select (string) | Yes      | The GA4 property ID. Select from the dropdown or enter manually. Options load from the selected connection. |

**Outputs**

| Field                  | Type   | Description                                                                           |
| ---------------------- | ------ | ------------------------------------------------------------------------------------- |
| Result Message         | string | A message indicating the result of the operation.                                     |
| Metadata Resource Name | string | The Google Analytics metadata resource name.                                          |
| Available Metrics      | array  | List of available metrics with their documented Google Analytics metadata fields.     |
| Available Dimensions   | array  | List of available dimensions with their documented Google Analytics metadata fields.  |
| Available Comparisons  | array  | List of available comparisons with their documented Google Analytics metadata fields. |
| Metric Count           | number | Total number of available metrics.                                                    |
| Dimension Count        | number | Total number of available dimensions.                                                 |
| Comparison Count       | number | Total number of available comparisons.                                                |

#### List Account Summaries

List all Google Analytics accounts and GA4 properties you have access to

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field     | Type    | Required | Description                                                                       |
| --------- | ------- | -------- | --------------------------------------------------------------------------------- |
| Page Size | integer | No       | Maximum number of account summaries to return (default 50, max 200). Default: 50. |

**Outputs**

| Field             | Type   | Description                                       |
| ----------------- | ------ | ------------------------------------------------- |
| Result Message    | string | A message indicating the result of the operation. |
| Account Summaries | array  | List of accounts with their GA4 properties.       |
| Total Accounts    | number | Total number of accounts returned.                |
| Total Properties  | number | Total number of properties across all accounts.   |

#### List Properties

List Google Analytics properties matching a filter expression

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field        | Type    | Required | Description                                                                                                                                                       |
| ------------ | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Filter       | string  | Yes      | Required filter expression for the Admin API. Examples: parent:accounts/123456, parent:properties/123456, ancestor:accounts/123456, firebase\_project:project-id. |
| Page Size    | integer | No       | Maximum number of properties to fetch per API page (default 50, max 200). Default: 50.                                                                            |
| Show Deleted | boolean | No       | Whether to include soft-deleted properties in the results. Default: false.                                                                                        |

**Outputs**

| Field            | Type        | Description                                                  |
| ---------------- | ----------- | ------------------------------------------------------------ |
| Result Message   | string      | A message indicating the result of the operation.            |
| Properties       | dict\_array | List of Google Analytics properties that matched the filter. |
| Total Properties | number      | Total number of properties returned.                         |

#### Get Property

Get a single Google Analytics property by property ID

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field       | Type            | Required | Description                                                                                                 |
| ----------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| Property ID | select (string) | Yes      | The GA4 property ID. Select from the dropdown or enter manually. Options load from the selected connection. |

**Outputs**

| Field          | Type   | Description                                       |
| -------------- | ------ | ------------------------------------------------- |
| Result Message | string | A message indicating the result of the operation. |
| Property       | dict   | The Google Analytics property details.            |

#### Check Compatibility

Check which metrics and dimensions can be used together in a report

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field       | Type            | Required | Description                                                                                                 |
| ----------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| Property ID | select (string) | Yes      | The GA4 property ID. Select from the dropdown or enter manually. Options load from the selected connection. |
| Metrics     | string          | No       | Comma-separated metric names to check compatibility for. Default: .                                         |
| Dimensions  | string          | No       | Comma-separated dimension names to check compatibility for. Default: .                                      |

**Outputs**

| Field                   | Type   | Description                                                 |
| ----------------------- | ------ | ----------------------------------------------------------- |
| Result Message          | string | A message indicating the result of the compatibility check. |
| Compatible Metrics      | array  | Metrics that are compatible with the given dimensions.      |
| Compatible Dimensions   | array  | Dimensions that are compatible with the given metrics.      |
| Incompatible Metrics    | array  | Metrics that are NOT compatible with the given dimensions.  |
| Incompatible Dimensions | array  | Dimensions that are NOT compatible with the given metrics.  |

#### List Data Streams

List all data streams (websites and apps) for a GA4 property

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field       | Type            | Required | Description                                                                                                 |
| ----------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| Property ID | select (string) | Yes      | The GA4 property ID. Select from the dropdown or enter manually. Options load from the selected connection. |
| Page Size   | integer         | No       | Maximum number of data streams to return (default 50, max 200). Default: 50.                                |

**Outputs**

| Field          | Type   | Description                                       |
| -------------- | ------ | ------------------------------------------------- |
| Result Message | string | A message indicating the result of the operation. |
| Data Streams   | array  | List of data streams for the property.            |
| Total Streams  | number | Total number of data streams returned.            |

#### List Audiences

List all configured audience segments for a GA4 property

**Required permissions:** `https://www.googleapis.com/auth/analytics.readonly`.

**Inputs**

| Field       | Type            | Required | Description                                                                                                 |
| ----------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| Property ID | select (string) | Yes      | The GA4 property ID. Select from the dropdown or enter manually. Options load from the selected connection. |
| Page Size   | integer         | No       | Maximum number of audiences to return (default 50, max 200). Default: 50.                                   |

**Outputs**

| Field           | Type   | Description                                            |
| --------------- | ------ | ------------------------------------------------------ |
| Result Message  | string | A message indicating the result of the operation.      |
| Audiences       | array  | List of configured audience segments for the property. |
| Total Audiences | number | Total number of audiences returned.                    |

### Important behavior

If an operation is denied, check the connection’s granted permissions and the account’s access in the provider. Reauthorize the connection when it needs additional permissions.

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/google-analytics.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
