Skip to main content
skill CX Codex

google-analytics · acedatacloud — Claude Code skill: GA4 reports and setup

A skill that pulls GA4 reports and property lists through the Google Analytics APIs, using curl and jq from the agent's shell.

Apache-2.0 177 installs ★ 17 updated 2026-10-25

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add AceDataCloud/Skills --skill google-analytics -a claude-code
Open on GitHub

What google-analytics does

The skill turns a question about site traffic into Google Analytics 4 API calls. It discovers properties through the Admin API at analyticsadmin.googleapis.com/v1beta, then runs reports against the Data API at analyticsdata.googleapis.com/v1beta. Everything happens in the shell with curl and jq; Bash is the only tool it is allowed to use.

Every request carries Authorization: Bearer $GOOGLE_ANALYTICS_TOKEN, and that token must have the analytics.readonly scope. No token in the environment, no report. Failures arrive as {"error":{"code","message","status"}} and are shown as-is, while a 401 means the token has to be installed again.

A report returns at most 10k rows by default and pages further with offset. Metric names have to be GA4 ids such as screenPageViews, not display labels, and the legacy analytics/v3 endpoints stay unused.

What it helps with

  • pull the top pages by views for the last 28 days
  • see which channels brought sessions
  • count active users by country
  • check who is on the site right now with a realtime report
  • find the numeric property id among reachable GA4 properties

Example prompts for the agent

  • Show the top 10 pages by views and active users for the last 28 days on property 123456789.
  • How many people are on the site right now? Run a realtime report by country.
  • List my GA4 properties and give me the numeric id of the main one.

How to install google-analytics

1Skills CLI (Vercel)

npx skills add AceDataCloud/Skills --skill google-analytics -a claude-code

2Manually: put the files in place

~/.claude/skills/google-analytics/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/google-analytics/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about google-analytics

How to install google-analytics in Claude Code?

Run npx skills add AceDataCloud/Skills --skill google-analytics -a claude-code. The skill lands at ~/.claude/skills/google-analytics/SKILL.md.

What does google-analytics do?

It queries GA4 reports through the Analytics Data API v1 and lists your properties through the Admin API. Access is read-only with the analytics.readonly scope.

Does it work with Universal Analytics?

No. It targets GA4 and Data API v1, and never touches the legacy analytics/v3 endpoints. You need a token in $GOOGLE_ANALYTICS_TOKEN for any call to go through.

Source text

SKILL.md · Apache-2.0
---
name: google-analytics
description: Query Google Analytics 4 (GA4) reports via the Analytics Data API v1 and list properties via the Admin API. Use when the user mentions Google Analytics, GA4, website traffic / sessions / users, top pages or sources, conversions, or a realtime report.
when_to_use: |
  Trigger when the user wants GA4 metrics — sessions, users, top
  pages / channels / countries, conversions, or live realtime users —
  for one of their GA4 properties. Read-only (`analytics.readonly`).
  List properties first to get the numeric property id.
connections: [google/analytics]
allowed_tools: [Bash]
license: Apache-2.0
metadata:
  author: acedatacloud
  version: "1.0"
---

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` (acquisition), `country` + `activeUsers` (geo), `eventName` +
`eventCount` / `conversions` (events). Dates accept `NdaysAgo`, `today`,
`yesterday`, or `YYYY-MM-DD`.

## Realtime

```bash
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"dimensions":[{"name":"country"}],"metrics":[{"name":"activeUsers"}]}' \
  "https://analyticsdata.googleapis.com/v1beta/properties/$PID:runRealtimeReport" | jq '.rows'
```

## Gotchas

- This is **GA4 only** (Data API v1). Old Universal Analytics (UA) is shut down —
  don't use the legacy `analytics/v3` endpoints.
- Valid dimension/metric API names matter (`screenPageViews`, not "Pageviews").
  If a name 400s, it's the wrong API id — check the GA4 dimensions & metrics list.
- Reports are capped by `limit` (default 10k rows); page with `offset`.

© acedatacloud · Apache-2.0 · AceDataCloud/Skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

google-analytics by other authors comes first.

From the same set67

The whole set →

Project sponsors

Companies that keep this analytics open