# Google Analytics Realtime Report (`google-analytics.realtime_report`)

Live Google Analytics 4 data for a property from the last 30 minutes (60 on Analytics 360): active users, events and more by dimension.

Docs: https://primaryapi.com/docs/api-reference/google-analytics/realtime_report

- Endpoint: `POST https://api.primaryapi.com/v1/run/google-analytics.realtime_report`
- Category: Web Intelligence · Platform: `google-analytics` · Kind: search · Status: live
- Price: 1 credit per call. Every call costs the same, including calls that were retried automatically.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=google-analytics.realtime_report`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `propertyId` | string | yes |  | pattern: ^(?:properties\/)?(\d{1,20})$ | GA4 property id, e.g. "123456789" (or "properties/123456789"), as google-analytics.properties lists it. |
| `dimensions` | string[] | no | [] | max 9 items; items max 200 chars; items pattern: ^[A-Za-z][A-Za-z0-9_:]*(?:\[[A-Za-z0-9_]+\])?$ | Dimensions to group by (API names, up to 9), e.g. ["date", "sessionDefaultChannelGroup"]. List them with google-analytics.metadata. |
| `metrics` | string[] | yes |  | min 1 items; max 10 items; items max 200 chars; items pattern: ^[A-Za-z][A-Za-z0-9_:]*(?:\[[A-Za-z0-9_]+\])?$ | Metrics to return (API names, 1-10), e.g. ["activeUsers", "sessions", "keyEvents"]. List them with google-analytics.metadata. |
| `dimensionFilter` | object | no |  |  | Optional GA4 FilterExpression on dimensions, e.g. {"filter":{"fieldName":"country","stringFilter":{"matchType":"EXACT","value":"France"}}}; combine with andGroup / orGroup / notExpression. |
| `metricFilter` | object | no |  |  | Optional GA4 FilterExpression on metrics, applied after aggregation, e.g. {"filter":{"fieldName":"sessions","numericFilter":{"operation":"GREATER_THAN","value":{"int64Value":"100"}}}}. |
| `orderBys` | object[] | no |  | max 10 items | Sort order, e.g. [{"metric":{"metricName":"sessions"},"desc":true}]. |
| `orderBys[].metric` | object | no |  |  |  |
| `orderBys[].dimension` | object | no |  |  |  |
| `orderBys[].desc` | boolean | no |  |  | Descending when true |
| `metricAggregations` | enum[] | no |  | max 4 items | Also return totals / minimums / maximums / counts of the metrics. |
| `minuteRanges` | object[] | no |  | min 1 items; max 2 items | Up to 2 minute ranges. Default: the last 30 minutes. Standard properties reach back 29 minutes, Analytics 360 properties 59. |
| `minuteRanges[].startMinutesAgo` | integer | no | 29 | 0–59 | Start, in minutes ago (default 29). |
| `minuteRanges[].endMinutesAgo` | integer | no | 0 | 0–59 | End, in minutes ago (default 0 = now). |
| `minuteRanges[].name` | string | no |  | max 100 chars | Optional name of the range. |
| `limit` | integer | no | 100 | 1–10000 | Maximum number of results to return (1-10000, default 100). |
| `connection` | string | no |  | max 200 chars | Which connected account to use when the workspace has several for this provider: the customId you gave it (exact), its connection id ("con_…"), its handle (login, email or @handle) or its name. Optional; prefer the customId or id, which never match two accounts. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `rows` | object[] |  |
| `rows[].dimensions` | object | Dimension values by API name |
| `rows[].metrics` | object | Metric values by API name (numbers) |
| `dimensionHeaders` | string[] |  |
| `metricHeaders` | object[] |  |
| `metricHeaders[].name` | string |  |
| `metricHeaders[].type` | string \| null | TYPE_INTEGER, TYPE_CURRENCY, … |
| `totals` | object[] |  |
| `totals[].dimensions` | object | Dimension values by API name |
| `totals[].metrics` | object | Metric values by API name (numbers) |
| `maximums` | object[] |  |
| `maximums[].dimensions` | object | Dimension values by API name |
| `maximums[].metrics` | object | Metric values by API name (numbers) |
| `minimums` | object[] |  |
| `minimums[].dimensions` | object | Dimension values by API name |
| `minimums[].metrics` | object | Metric values by API name (numbers) |
| `rowCount` | integer \| null | Rows in the whole result, regardless of limit |
| `propertyQuota` | object \| null | The property’s Data API quota after this call (tokensPerDay, tokensPerHour, …) |
| `nextCursor` | string \| null |  |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/google-analytics.realtime_report" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"propertyId":"312345678","dimensions":["country"],"metrics":["activeUsers"]}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "rows": [
        {
          "dimensions": {
            "country": "United States"
          },
          "metrics": {
            "activeUsers": 42
          }
        },
        {
          "dimensions": {
            "country": "Germany"
          },
          "metrics": {
            "activeUsers": 7
          }
        }
      ],
      "dimensionHeaders": [
        "country"
      ],
      "metricHeaders": [
        {
          "name": "activeUsers",
          "type": "TYPE_INTEGER"
        }
      ],
      "totals": [],
      "maximums": [],
      "minimums": [],
      "rowCount": 2,
      "propertyQuota": null,
      "nextCursor": null
    }
  },
  "provider": "PrimaryAPI",
  "credits": 1,
  "items": 2,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
  "nextCursor": null
}
```

## Pricing and reliability

- Usual price: 1 credit per call
- Price ceiling: the usual price, even when a call is retried. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=google-analytics.realtime_report`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Runs as your connected Google account and needs the Read Google Analytics capability (analytics_read). Only realtime dimensions and metrics work here (for example country, city, deviceCategory, unifiedScreenName, eventName; activeUsers, eventCount, screenPageViews). One page of up to 10,000 rows, no paging.

