<!-- BusyBot node reference — https://busybot.net/tools/google-analytics/ -->

> Node: Google Analytics (`google_analytics`) · Action · v1
> Category: Analytics · Credentials: Google Analytics OAuth2 (`googleAnalyticsOAuth2Api`)
> Updated: 2026-08-16

# Google Analytics

> Retrieve GA4 and Universal Analytics reports and user activity

## Overview

Google Analytics is a web analytics service. This tool supports GA4 (Google Analytics 4) via the Analytics Data API and Universal Analytics (UA) via the Analytics Reporting API v4. For GA4: run reports with metrics, dimensions, filters, and order-by options. For UA: run batch reports and search user activity sessions by client ID. All operations use Google OAuth2 authentication.

**Category:** Analytics  
**Tool Name:** `google_analytics`  
**Version:** 1

**Appearance:** Icon: `lucide-BarChart` | Color: `#F9AB00`

## Node Type

**Action** — processes input items and produces output

## Input / Output

| Direction | Port(s) |
|-----------|--------|
| Input | `Input` |
| Output | `Output`, `Error` |

## Credentials

This tool requires **Google Analytics OAuth2** credentials.
See the [Credentials Guide](https://busybot.net/credentials/google-analytics-oauth2-api/) for setup instructions.

### Resources

| Resource | Value |
|----------|-------|
| Report | `report` |
| User Activity | `userActivity` |

### Operations

| Operation | Value | Description |
|-----------|-------|-------------|
| Report: Get | `get` | Return the analytics report data |
| User Activity: Search | `search` | Return user activity data for a given user ID |

### Parameters

#### Report: Get

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| Property Type | `options` | No | `ga4` | Which version of Google Analytics to query. |
| | | | | Options: `ga4` (Google Analytics 4 (GA4)), `universal` (Universal Analytics (UA)) |
| Property ID | `string` | Yes | — | The GA4 Property ID (numeric). Found in Google Analytics under Admin → Property Settings. _(shown when Property Type is `ga4`)_ |
| Date Range (`dateRange`) | `options` | Yes | `last7days` | The date range for the GA4 report. _(shown when Property Type is `ga4`)_ |
| | | | | Options: `today`, `yesterday`, `lastCalendarWeek` (Last Complete Calendar Week), `last7days`, `last14days`, `last28days`, `last30days`, `last90days`, `last12months`, `lastCalendarMonth` (Last Complete Calendar Month), `lastCalendarYear` (Last Complete Calendar Year), `thisCalendarYear`, `custom` |
| Start Date (`startDate`) | `dateTime` | Yes | — | Start date for the custom date range (YYYY-MM-DD or ISO datetime). _(shown when Property Type is `ga4` and Date Range is `custom`)_ |
| End Date (`endDate`) | `dateTime` | Yes | — | End date for the custom date range (YYYY-MM-DD or ISO datetime). _(shown when Property Type is `ga4` and Date Range is `custom`)_ |
| Metrics (`metricsGA4`) | `fixedCollection` | No | `{"metricValues":[{"name":"totalUsers"}]}` | Quantitative measurements for the GA4 report (e.g. totalUsers, sessions, pageViews). Up to 10 metrics allowed. _(shown when Property Type is `ga4`)_ |
| — Metric Name | `options` | No | `totalUsers` | The GA4 metric to include in the report. |
| | | | | Options: `activeUsers`, `averageSessionDuration`, `bounceRate`, `conversions`, `engagementRate`, `eventCount`, `newUsers`, `screenPageViews` (Page Views), `purchaseRevenue`, `sessions`, `sessionsPerUser`, `totalUsers`, `custom` (Custom Metric) |
| — Custom Metric Name | `string` | No | — | The exact GA4 API name for the custom metric. _(shown when Metric Name is `custom`)_ |
| — Expression | `string` | No | — | A mathematical expression for derived metrics (optional). _(shown when Metric Name is `custom`)_ |
| Dimensions to Split By (`dimensionsGA4`) | `fixedCollection` | No | `{"dimensionValues":[{"name":"date"}]}` | Attributes to split the GA4 report by (e.g. date, country, deviceCategory). Up to 9 dimensions allowed. _(shown when Property Type is `ga4`)_ |
| — Dimension Name (`name`) | `options` | No | `date` | The GA4 dimension to split the report by. |
| | | | | Options: `browser`, `city`, `country`, `date`, `dateHour`, `deviceCategory`, `eventName`, `landingPage`, `medium`, `operatingSystem`, `pagePath`, `pageTitle`, `platform`, `sessionDefaultChannelGroup`, `sessionSource`, `sessionSourceMedium`, `source`, `week`, `year`, `other` (Other (specify below)) |
| — Custom Dimension Name (`customName`) | `string` | No | — | The exact GA4 API name for the dimension when "Other" is selected. _(shown when Dimension Name is `other`)_ |
| Simplify Output (`simplify`) | `boolean` | No | `true` | Whether to return a simplified flat object per row instead of the raw API response. When enabled, dimension and metric names become object keys. _(shown when Property Type is `ga4`)_ |
| Keep Empty Rows | `boolean` | No | `false` | Whether to include rows where all metrics are zero. _(shown when Property Type is `ga4`)_ |
| Return All (`returnAll`) | `boolean` | No | `false` | Whether to return all rows or only up to a given limit. _(shown when Property Type is `ga4`)_ |
| Limit (`limit`) | `number` | No | `50` | Max number of rows to return. _(shown when Property Type is `ga4` and Return All is `false`)_ |
| Additional Fields (`additionalFieldsGA4`) | `collection` | No | `{}` | _(shown when Property Type is `ga4`)_ |
| — Currency Code | `string` | No | — | ISO 4217 currency code. If empty, uses the property default. |
| — Dimension Filter (JSON) | `json` | No | `{}` | A GA4 FilterExpression object for filtering by dimensions. See https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/FilterExpression for schema. |
| — Metric Filter (JSON) | `json` | No | `{}` | A GA4 FilterExpression object for filtering by metrics. See https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/FilterExpression for schema. |
| — Order By (JSON) | `json` | No | `[]` | Array of GA4 OrderBy objects. Each has optional "desc" (bool) and either "metric" (metricName) or "dimension" (dimensionName, orderType). E.g. [{"desc":true,"metric":{"metricName":"sessions"}}] |
| View ID (`viewId`) | `string` | Yes | — | The Universal Analytics View (Profile) ID. Found in Google Analytics under Admin → View Settings. _(shown when Property Type is `universal`)_ |
| Date Range (`dateRange`) | `options` | Yes | `last7days` | The date range for the UA report. _(shown when Property Type is `universal`)_ |
| | | | | Options: `today`, `yesterday`, `lastCalendarWeek` (Last Complete Calendar Week), `last7days`, `last14days`, `last28days`, `last30days`, `last90days`, `last12months`, `lastCalendarMonth` (Last Complete Calendar Month), `lastCalendarYear` (Last Complete Calendar Year), `thisCalendarYear`, `custom` |
| Start Date (`startDate`) | `dateTime` | Yes | — | Start date for the custom date range (YYYY-MM-DD or ISO datetime). _(shown when Property Type is `universal` and Date Range is `custom`)_ |
| End Date (`endDate`) | `dateTime` | Yes | — | End date for the custom date range (YYYY-MM-DD or ISO datetime). _(shown when Property Type is `universal` and Date Range is `custom`)_ |
| Metrics (`metricsUA`) | `fixedCollection` | No | `{"metricValues":[{"listName":"ga:users"}]}` | Metrics for the UA report. Use ga: prefix (e.g. ga:sessions, ga:pageviews, ga:users). _(shown when Property Type is `universal`)_ |
| — Metric | `options` | No | `ga:users` | The UA metric expression. |
| | | | | Options: `ga:productCheckouts` (Checkouts), `ga:totalEvents` (Events), `ga:pageviews` (Page Views), `ga:sessionDuration` (Session Duration), `ga:sessions` (Sessions), `ga:sessionsPerUser` (Sessions per User), `ga:users` (Total Users), `other` (Other metrics…), `custom` (Custom metric…) |
| — Name / Expression | `string` | No | — | The ga: metric expression (when "Other metrics…" is selected) or alias (for custom). _(shown when Metric is `other`, `custom`)_ |
| — Custom Expression | `string` | No | — | Custom metric expression (for "Custom metric…" only). _(shown when Metric is `custom`)_ |
| — Formatting Type | `options` | No | `INTEGER` | How the metric expression should be formatted (for "Custom metric…" only). _(shown when Metric is `custom`)_ |
| | | | | Options: `CURRENCY`, `FLOAT`, `INTEGER`, `PERCENT`, `TIME` |
| Dimensions to Split By (`dimensionsUA`) | `fixedCollection` | No | `{"dimensionValues":[{"listName":"ga:date"}]}` | Dimensions for the UA report. Use ga: prefix (e.g. ga:date, ga:country). _(shown when Property Type is `universal`)_ |
| — Dimension | `options` | No | `ga:date` | The UA dimension to split the report by. |
| | | | | Options: `ga:browser` (Browser), `ga:campaign` (Campaign), `ga:city` (City), `ga:country` (Country), `ga:date` (Date), `ga:deviceCategory` (Device Category), `ga:productName` (Item Name), `ga:language` (Language), `ga:pagePath` (Page), `ga:sourceMedium` (Source / Medium), `other` (Other dimensions…) |
| — Custom Dimension Name (`name`) | `string` | No | — | The ga: dimension name when "Other dimensions…" is selected. _(shown when Dimension is `other`)_ |
| Simplify Output (`simplify`) | `boolean` | No | `true` | Whether to return simplified flat row objects instead of the raw batchGet report structure. _(shown when Property Type is `universal`)_ |
| Return All (`returnAll`) | `boolean` | No | `false` | Whether to return all rows or only up to a given limit. _(shown when Property Type is `universal`)_ |
| Limit (`limit`) | `number` | No | `50` | Max number of rows to return (per-page, for UA pagination pageSize). _(shown when Property Type is `universal` and Return All is `false`)_ |
| Additional Fields (`additionalFieldsUA`) | `collection` | No | `{}` | _(shown when Property Type is `universal`)_ |
| — Use Resource Quotas | `boolean` | No | `false` | Whether to enable resource-based quotas (requires Analytics 360). |
| — Dimension Filters | `fixedCollection` | No | `{}` | Filters on UA dimension values. |
| — — Dimension Name (`dimensionName`) | `string` | No | — | The GA dimension to filter on. |
| — — Operator | `options` | No | `EXACT` | The filter operator. |
| | | | | Options: `BEGINS_WITH`, `ENDS_WITH`, `NUMERIC_EQUAL` (Equals (Number)), `EXACT` (Exactly Matches), `NUMERIC_GREATER_THAN` (Greater Than (Number)), `NUMERIC_LESS_THAN` (Less Than (Number)), `PARTIAL` (Partly Matches), `REGEXP` (Regular Expression) |
| — — Value | `string` | No | — | The value or regular expression to match against. |
| — Include Empty Rows | `boolean` | No | `false` | Whether to include rows where all metrics equal zero. |
| — Hide Totals | `boolean` | No | `false` | Whether to hide the totals row from the response. |
| — Hide Value Ranges | `boolean` | No | `false` | Whether to hide minimum and maximum values. |

#### User Activity: Search

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| View ID (`viewId`) | `string` | Yes | — | The Universal Analytics View (Profile) ID to search user activity in. |
| User ID | `string` | Yes | — | The Client ID (ga: cookie value) or User ID to search activity for. |
| Return All (`returnAll`) | `boolean` | No | `false` | Whether to return all sessions or only up to a given limit. |
| Limit (`limit`) | `number` | No | `100` | Max number of sessions to return per page. _(shown when Return All is `false`)_ |
| Additional Fields (`additionalFieldsUA`) | `collection` | No | `{}` | — |
| — Activity Types | `multiOptions` | No | `[]` | Filter activity by type. If empty, all activity types are returned. |
| | | | | Options: `ECOMMERCE`, `EVENT`, `GOAL`, `PAGEVIEW`, `SCREENVIEW` |

#### All Operations

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| Authentication | `options` | No | `oAuth2` | Authentication method to use. |
| | | | | Options: `oAuth2` (OAuth2 (recommended)), `serviceAccount` |
| Google Account | `credential` | No | — | Connect or select your Google account. _(shown when Authentication is `oAuth2`)_ |
| Service Account Email | `string` | Yes | — | The email address of the Google service account. _(shown when Authentication is `serviceAccount`)_ |
| Private Key | `string` | Yes | — | The private key from the service account JSON key file. _(shown when Authentication is `serviceAccount`)_ |
| Max Concurrency | `number` | No | `5` | Maximum number of items to process concurrently. |

## Output Data

This node **fans out and replaces**: it emits one output item per report row (or per session), and each output item's JSON is the row itself. The input item's fields do **not** pass through, and binary data is not forwarded — carry anything you still need downstream in a Merge node instead.

What lands on each item depends on the operation and on Simplify Output:

| Operation | Simplify Output | Output items |
|-----------|-----------------|--------------|
| `Report: Get` (GA4) | on (default) | One item per row, a flat object keyed by the dimension and metric names you selected — e.g. `date`, `country`, `totalUsers` |
| `Report: Get` (GA4) | off | A single item carrying the raw Data API `runReport` response, headers and all |
| `Report: Get` (UA) | on (default) | One item per row, a flat object keyed by the `ga:` dimension and metric names you selected — e.g. `ga:date`, `ga:sessions` |
| `Report: Get` (UA) | off | A single item carrying the raw `batchGet` report structure, with every page's rows merged into it |
| `User Activity: Search` | not applicable | One item per session returned by the user activity search |

Metric values arrive as **strings**, not numbers — the Analytics APIs return them that way. Cast before arithmetic, for example `{{ Number($json.totalUsers) }}`.

A report that matches no rows produces no output items at all, so a downstream node may receive nothing.

## Usage Examples

- Get a GA4 report for the last 7 days with sessions and pageViews metrics
- Get a Universal Analytics report for last 30 days split by date and country
- Search user activity sessions by client ID in a UA view
- Get GA4 report with dimension and metric filters
- Return all GA4 report rows without pagination limit

## Example Configuration

Daily users and sessions from a GA4 property, last 30 days:

```json
{
  "type": "google_analytics",
  "parameters": {
    "resource": "report",
    "operation": "get",
    "propertyType": "ga4",
    "propertyId": "123456789",
    "dateRange": "last30days",
    "metricsGA4": {
      "metricValues": [
        {
          "name": "totalUsers"
        },
        {
          "name": "sessions"
        }
      ]
    },
    "dimensionsGA4": {
      "dimensionValues": [
        {
          "name": "date"
        }
      ]
    },
    "simplify": true,
    "returnAll": true
  }
}
```

GA4 traffic split by device and country over a custom date range, ordered by users:

```json
{
  "type": "google_analytics",
  "parameters": {
    "resource": "report",
    "operation": "get",
    "propertyType": "ga4",
    "propertyId": "123456789",
    "dateRange": "custom",
    "startDate": "2026-01-01",
    "endDate": "2026-01-31",
    "metricsGA4": {
      "metricValues": [
        {
          "name": "totalUsers"
        },
        {
          "name": "averageSessionDuration"
        }
      ]
    },
    "dimensionsGA4": {
      "dimensionValues": [
        {
          "name": "deviceCategory"
        },
        {
          "name": "country"
        }
      ]
    },
    "returnAll": false,
    "limit": 500,
    "additionalFieldsGA4": {
      "orderBys": "[{\"desc\":true,\"metric\":{\"metricName\":\"totalUsers\"}}]"
    }
  }
}
```

Universal Analytics source/medium report, filtered to one country:

```json
{
  "type": "google_analytics",
  "parameters": {
    "resource": "report",
    "operation": "get",
    "propertyType": "universal",
    "viewId": "12345678",
    "dateRange": "last30days",
    "metricsUA": {
      "metricValues": [
        {
          "listName": "ga:users"
        },
        {
          "listName": "ga:sessions"
        }
      ]
    },
    "dimensionsUA": {
      "dimensionValues": [
        {
          "listName": "ga:sourceMedium"
        }
      ]
    },
    "simplify": true,
    "returnAll": true,
    "additionalFieldsUA": {
      "includeEmptyRows": false,
      "dimensionFiltersUi": {
        "filterValues": [
          {
            "dimensionName": "ga:country",
            "operator": "EXACT",
            "expressions": "United States"
          }
        ]
      }
    }
  }
}
```

Look up one visitor’s pageviews and events:

```json
{
  "type": "google_analytics",
  "parameters": {
    "resource": "userActivity",
    "operation": "search",
    "viewId": "12345678",
    "userId": "GA1.2.1234567890.1234567890",
    "returnAll": false,
    "limit": 50,
    "additionalFieldsUA": {
      "activityTypes": [
        "PAGEVIEW",
        "EVENT"
      ]
    }
  }
}
```

### Error Handling

| Mode | Behavior |
|------|----------|
| **stop** | Halts workflow on first error |
| **continue** | Skips failed items, passes successful ones through |
| **errorPort** | Routes failed items to Error output port |

## Tips

Retrieve GA4 and Universal Analytics reports including metrics, dimensions, and user activity sessions. Use when you need website analytics data, traffic reports, or user behavior analysis from Google Analytics. Returns report rows with metric values and dimension breakdowns.

### Choosing a property type

- **GA4** queries the Data API by numeric **Property ID**, found under Admin → Property Settings. Metric and dimension names have no prefix (`totalUsers`, `deviceCategory`).
- **Universal Analytics** queries the Reporting API by **View ID**, found under Admin → View Settings. Metric and dimension names keep the `ga:` prefix (`ga:users`, `ga:country`).
- **User Activity** is Universal Analytics only, and takes a View ID plus the client or user ID whose sessions you want.

### Behavior notes

- **GA4 allows up to 10 metrics and 9 dimensions per report.** More than that and the API rejects the query.
- **Pick "Custom Metric" or "Other" to reach names not in the dropdown.** The dropdown covers the common ones; the custom fields take any exact API name, and GA4 custom metrics additionally accept a derived expression such as `eventCount/totalUsers`.
- **Turn Simplify Output off only when you need the envelope.** Simplified rows are what most workflows want; the raw response is useful when you need headers, totals or quota metadata.
- **Keep Empty Rows / Include Empty Rows brings back all-zero rows.** Leave them off to avoid padding a report with rows nothing happened on.
- **Return All pages the API until it is exhausted.** On a large property that is many round trips — set a limit while you are building the workflow.