google-analyticslisted
Install: claude install-skill AceDataCloud/Skills
Query **Google Analytics 4** via `curl + jq`. The user's OAuth bearer token is in
`$GOOGLE_ANALYTICS_TOKEN` (scope `analytics.readonly`); every call needs
`Authorization: Bearer $GOOGLE_ANALYTICS_TOKEN`. Two APIs: the **Admin API**
(`analyticsadmin.googleapis.com/v1beta`) to discover properties, and the **Data
API** (`analyticsdata.googleapis.com/v1beta`) to run reports.
Failures are `{"error":{"code","message","status"}}` — show verbatim. `401` =
re-install.
```bash
AUTH="Authorization: Bearer $GOOGLE_ANALYTICS_TOKEN"
# List the GA4 properties the user can access (via their account summaries)
curl -sS -H "$AUTH" "https://analyticsadmin.googleapis.com/v1beta/accountSummaries" \
| jq '.accountSummaries[]?.propertySummaries[]? | {property, displayName}'
```
`property` looks like `properties/123456789` — the number is the `PROPERTY_ID`.
## Run a report
```bash
PID="123456789"
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" -d '{
"dateRanges":[{"startDate":"28daysAgo","endDate":"today"}],
"dimensions":[{"name":"pagePath"}],
"metrics":[{"name":"screenPageViews"},{"name":"activeUsers"}],
"orderBys":[{"metric":{"metricName":"screenPageViews"},"desc":true}],
"limit":10
}' "https://analyticsdata.googleapis.com/v1beta/properties/$PID:runReport" \
| jq '.rows[] | {page: .dimensionValues[0].value, views: .metricValues[0].value, users: .metricValues[1].value}'
```
Swap dimensions/metrics for other reports: `sessionDefaultChannelGroup` +
`sessions` (acqu