# Run a Google Analytics (GA4) report

Runs a Google Analytics (GA4) report.

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

- 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
- `dateRanges`, array of object: At least 1 item. Up to 4 items
  - `startDate`, string, required
  - `endDate`, string, required
  - `name`, string
- `offset`, integer: At least 0
- `keepEmptyRows`, boolean
- `currencyCode`, string

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/analytics/googleanalytics/report" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "metrics": [
    "string"
  ],
  "dateRanges": [
    {
      "startDate": "string",
      "endDate": "string"
    }
  ],
  "offset": 1,
  "keepEmptyRows": true
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/analytics/googleanalytics/report", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9",
    metrics: [
      "string"
    ],
    dateRanges: [
      {
        startDate: "string",
        endDate: "string"
      }
    ],
    offset: 1,
    keepEmptyRows: true
  }),
});
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/report",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "metrics": [
            "string",
        ],
        "dateRanges": [
            {
                "startDate": "string",
                "endDate": "string",
            },
        ],
        "offset": 1,
        "keepEmptyRows": True,
    },
    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": {}
}
```
