google-analytics
Read Google Analytics 4 website tracking data through the Google Analytics Data API. Connect a Google account with OAuth2
Connect this API to an AI agent Browse all specs
What you can do with google-analytics via MCP
Every endpoint below becomes a governed tool your AI agent (Claude, ChatGPT, or a customer-facing VX agent) can call — with scoped permissions, sandbox testing, and audit logs.
| Method | Path | Operation | Description |
|---|---|---|---|
| POST | /v1beta/properties/{propertyId}:runReport |
runGoogleAnalyticsReport | Run a historical GA4 report |
| POST | /v1beta/properties/{propertyId}:runRealtimeReport |
runGoogleAnalyticsRealtimeReport | Run a realtime GA4 report |
| GET | /v1beta/properties/{propertyId}/metadata |
getGoogleAnalyticsMetadata | List dimensions and metrics available to a GA4 property |
| POST | /v1beta/properties/{propertyId}:checkCompatibility |
checkGoogleAnalyticsCompatibility | Check dimension and metric compatibility |
Authentication
GoogleAnalyticsOAuth2
OAuth 2.0
Scopes: https://www.googleapis.com/auth/analytics.readonly
Google OAuth2 Authorization Code flow with PKCE. The authorization URL requests offline access and explicit consent so Google can return a refresh token.
Usage guide
Connect
- Add to agent, then Connect Google in the agent's Connections tab. No Google Cloud project or API key is needed.
- Sign in with a Google account that has at least Viewer access to the GA4 property. Access is read-only (
analytics.readonly). - Find the numeric Property ID in Google Analytics → Admin → Property details (for example
123456789, not theG-XXXXmeasurement ID). Tell the agent, or pin it as a preset parameter so every call uses it.
What the agent can do
| Tool | Use it for |
|---|---|
runGoogleAnalyticsReport |
Historical reports: sessions, users, conversions, revenue by date, source, page, country… |
runGoogleAnalyticsRealtimeReport |
Active users in the last 30 minutes |
getGoogleAnalyticsMetadata |
List the dimensions and metrics this property supports (including custom ones) |
checkGoogleAnalyticsCompatibility |
Check that a dimension + metric combination is valid before running a report |
Tips
- Start with
getGoogleAnalyticsMetadatawhen a metric name is unclear; GA4 names differ from Universal Analytics (sessions,activeUsers,keyEvents,totalRevenue). - Use relative dates such as
7daysAgo,yesterday,today. - If a report returns 400, run
checkGoogleAnalyticsCompatibility; some dimensions cannot be combined with some metrics. - A 403 means the connected Google account has no access to that property: reconnect with the right account or ask the property admin for Viewer access.
This connector cannot change Analytics settings or data.
How to use this spec
- Create a free VX Agents account (sandbox tools included).
- Open the marketplace and connect “google-analytics” to an agent.
- Expose it as an MCP server for Claude/ChatGPT, or chat with it directly.