# Run a Google Analytics (GA4) realtime report

Runs a Google Analytics (GA4) realtime report.

```http
POST https://api.pozy.ai/v1/analytics/googleanalytics/realtime
```

- Area: Analytics / Analytics
- Auth: Authorization: Bearer pz_live_...

## Request body

Content type: `application/json`

- `accountId`, string, required
- `dimensions`, array of string: Up to 9 items
- `metrics`, array of string, required: At least 1 item. Up to 10 items
- `dimensionFilter`, object
- `metricFilter`, object
- `orderBys`, array of object: Up to 10 items
- `limit`, integer: 1 to 10000
- `minuteRanges`, array of object: At least 1 item. Up to 2 items
  - `startMinutesAgo`, integer: 0 to 59
  - `endMinutesAgo`, integer: 0 to 59
  - `name`, string

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/analytics/googleanalytics/realtime" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "metrics": [
    "string"
  ],
  "minuteRanges": [
    {
      "startMinutesAgo": 1,
      "endMinutesAgo": 1,
      "name": "Acme"
    }
  ]
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/analytics/googleanalytics/realtime", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9",
    metrics: [
      "string"
    ],
    minuteRanges: [
      {
        startMinutesAgo: 1,
        endMinutesAgo: 1,
        name: "Acme"
      }
    ]
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/analytics/googleanalytics/realtime",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "metrics": [
            "string",
        ],
        "minuteRanges": [
            {
                "startMinutesAgo": 1,
                "endMinutesAgo": 1,
                "name": "Acme",
            },
        ],
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `accountId`, string
- `propertyId`, string
- `dimensionHeaders`, array of object
  - `name`, string
- `metricHeaders`, array of object
  - `name`, string
  - `type`, string
- `rows`, array of object
  - `dimensionValues`, array of object
    - `value`, string
  - `metricValues`, array of object
    - `value`, string
- `rowCount`, integer
- `metadata`, object
- `propertyQuota`, object

```json
{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "propertyId": "67197e35a04da83e86751673",
  "dimensionHeaders": [
    {
      "name": "Acme"
    }
  ],
  "metricHeaders": [
    {
      "name": "Acme",
      "type": "string"
    }
  ],
  "rows": [
    {
      "dimensionValues": [
        {
          "value": "string"
        }
      ],
      "metricValues": [
        {
          "value": "string"
        }
      ]
    }
  ],
  "rowCount": 42,
  "metadata": {},
  "propertyQuota": {}
}
```
