# Google Analytics — how to use (mcp.ai)

Connect your Google Analytics account and use 4 tools for analytics straight from your AI agent. Connect in one click, no API key needed. Google Analytics tracks and reports website traffic, user behavior, and conversion data, enabling marketers to optimize online performance and customer journeys.

## Option A — via MCP (recommended)
Remote MCP endpoint (HTTP, streamable): `https://api.mcp.ai/p_google_analytics?ms=1796396520000`
Add it as a custom/remote MCP connector in your client (Claude, Cursor, VS Code…), then authenticate when prompted. Once connected, ask the agent to use the server's tools (e.g. `google_analytics_check_compatibility`).

## Option B — via direct REST API
Base URL: `https://api.mcp.ai/api/google_analytics`
Auth: `Authorization: Bearer sk_live_…` — create a workspace API key at https://new.mcp.ai/settings/api-keys
Discover endpoints: `GET https://api.mcp.ai/api/google_analytics/_endpoints`

### Endpoints
- `POST https://api.mcp.ai/api/google_analytics/check/compatibility` — Check whether a set of dimensions and metrics can be combined in the same report before running it. Not every pair is valid in GA4.
  - body: { property_id: string, dimensions?: object[], metrics?: object[], dimensionFilter?: object, metricFilter?: object, compatibilityFilter?: string }
- `POST https://api.mcp.ai/api/google_analytics/create/expanded/data/set` — Tool to create an expanded data set for a property. use when you need to combine specific dimensions and metrics into a custom dataset after property creation.
  - body: { parent: string, expandedDataSet: object }
- `POST https://api.mcp.ai/api/google_analytics/get/account` — Tool to retrieve a single account by its resource name. use when you need detailed account info after confirming the account resource name (e.g., accounts/100).
  - body: { name: string }
- `POST https://api.mcp.ai/api/google_analytics/get/metadata` — List every dimension and metric this property accepts, including the custom ones. Call this when unsure which names a report can use.
  - body: { property_id: string }
- `POST https://api.mcp.ai/api/google_analytics/list/accounts` — Tool to list all accounts accessible by the caller. use when you need to enumerate all google analytics accounts your credentials can access.
  - body: { pageSize?: integer, pageToken?: string, showDeleted?: boolean }
- `POST https://api.mcp.ai/api/google_analytics/list/audiences` — Tool to list all audiences on a property. use when you need to fetch all audiences for a ga4 property after confirming its existence.
  - body: { parent: string, pageSize?: integer, pageToken?: string }
- `POST https://api.mcp.ai/api/google_analytics/list/key/events` — List the property's key events (what GA4 counts as a conversion). Use to learn which event names are worth reporting on.
  - body: { property_id: string, pageSize?: integer, pageToken?: string }
- `POST https://api.mcp.ai/api/google_analytics/list/properties` — List every Google Analytics account the connected user can see, each with its GA4 properties (id + display name). Start here: every other tool needs a property_id.
  - body: { pageSize?: integer, pageToken?: string }
- `POST https://api.mcp.ai/api/google_analytics/run/funnel/report` — Funnel report: how many people advance through each step and where they drop off. Use for 'where are people abandoning the checkout'.
  - body: { property_id: string, dateRanges: object[], funnel: object, funnelBreakdown?: object, funnelNextAction?: object, limit?: integer }
- `POST https://api.mcp.ai/api/google_analytics/run/pivot/report` — Cross two or more dimensions in a pivot table (e.g. channel by month). Use when a flat report would need one row per combination.
  - body: { property_id: string, dateRanges: object[], dimensions?: object[], metrics: object[], pivots: object[], dimensionFilter?: object }
- `POST https://api.mcp.ai/api/google_analytics/run/realtime/report` — Who is on the site right now: realtime report for the last 30 minutes. Use for 'how many people are online', not for historical periods.
  - body: { property_id: string, dimensions?: object[], metrics: object[], dimensionFilter?: object, limit?: integer }
- `POST https://api.mcp.ai/api/google_analytics/run/report` — Run a Google Analytics report: users, sessions, pageviews, conversions and revenue, broken down by any dimension (date, channel, source, page, country, device). This is the main tool for questions abo
  - body: { property_id: string, dateRanges: object[], dimensions?: object[], metrics: object[], dimensionFilter?: object, metricFilter?: object, orderBys?: object[], limit?: integer, offset?: integer, keepEmptyRows?: boolean }

## Example prompts
- "What can I do in Google Analytics?"
- "Show me a summary of my Google Analytics account"

## More
- Page: https://new.mcp.ai/google_analytics
- Agent spec (llms.txt): https://new.mcp.ai/google_analytics/llms.txt
- Postman collection: https://new.mcp.ai/google_analytics/postman.json
