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

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=1781541840000`
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_create_expanded_data_set`).

## 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://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/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/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 }

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