Google Analytics 4
Query Google Analytics 4 (account/property metadata, custom dimensions/metrics, core reports, realtime reports, funnel reports) from any AI agent. 8 tools, OAuth2 user auth.
7 æ¥éç¡æ · ã¯ã¬ãžããã«ãŒãäžèŠ Â· EU ãã¹ã
Google ã«äœã§ãèãã
AnythingMCP çµç±ã§ Google Analytics 4 ã«å®éã®ããã³ããã詊ãã â Claude ãããŒã«ãåŒã³åºããåçããŸããããªãã®ã¡ãã»ãŒãžã§ Enter ãæŒããš Cloud ã«ã€ã³ã¹ããŒã«ããŸãã
Google ã Cloud ã«ã€ã³ã¹ããŒã«Claude 㯠AI ã®ãã誀ãããšããããŸããåçãã確èªãã ããã
2 åã§ã»ããã¢ãã
- 1cloud.anythingmcp.com ã§ç¡æãã©ã€ã¢ã«éå§ã
- 2ã³ãã¯ã¿ãŒã¹ãã¢ã§ Google Analytics 4 ãã¯ãªãã¯ãè³æ Œæ å ±ã貌ãä»ãã
- 3MCP API ããŒãçºè¡ããAI ã¯ã©ã€ã¢ã³ãã MCP URL ã«åããã
Google ã®ã¬ã€ã
äž»èŠ AI ã¯ã©ã€ã¢ã³ãåãã®ã¹ããããã€ã¹ãããã»ããã¢ããã
Google Analytics 4 ã®ã»ããã¢ãã
ã³ãã¯ã¿å®çŸ©ãã®ãã®ããïŒèªèšŒæ å ±ã®å ¥æå ãå¿ èŠãªæš©éããã®ã¢ããã¿ãåŒã³åºã APIã ã³ãã¯ã¿äœè ã«ããè±èªã§æäŸãããŠããŸãã
This connector wraps the Google Analytics Data API v1beta (analyticsdata.googleapis.com) and Admin API v1beta (analyticsadmin.googleapis.com).
Setup (one-time, about 10 minutes):
- Go to https://console.cloud.google.com â pick or create a project.
- APIs & Services â Library â enable both:
- Google Analytics Admin API (https://console.cloud.google.com/apis/library/analyticsadmin.googleapis.com)
- Google Analytics Data API (https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com)
- APIs & Services â OAuth consent screen: Internal on Google Workspace, otherwise External with publishing status In production. While an app is in Testing, Google revokes its refresh tokens after 7 days.
- APIs & Services â Credentials â Create Credentials â OAuth client ID â application type Web application â authorized redirect URI
https://cloud.anythingmcp.com/api/mcp-oauth/callbackon AnythingMCP Cloud, or<your AnythingMCP server URL>/api/mcp-oauth/callbackwhen you host AnythingMCP yourself. - Paste the client ID and secret into
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET, leaveGOOGLE_REFRESH_TOKENempty, and install. - On the connector page, click Authorize with Provider and sign in with a Google account that has access to your GA4 properties. The refresh token is stored encrypted and access tokens are renewed automatically.
Scope: https://www.googleapis.com/auth/analytics.readonly. The authorization URL carries access_type=offline&prompt=consent, so Google returns a refresh token every time you authorize.
Already have a refresh token? You can paste it into GOOGLE_REFRESH_TOKEN instead of step 6, for example one minted in the OAuth Playground (https://developers.google.com/oauthplayground â âïž â 'Use your own OAuth credentials') with the scope above (add https://developers.google.com/oauthplayground as a redirect URI of the client first). It must come from the same OAuth client as GOOGLE_CLIENT_ID.
Authentication: OAuth2 with refresh â the engine exchanges refresh_token â access_token against https://oauth2.googleapis.com/token automatically and sends Authorization: Bearer ACCESS_TOKEN on every call. Tokens are cached and refreshed on 401.
Service accounts are NOT supported yet â they require JWT RS256 signing which our engine doesn't do. Workaround: create a dedicated 'automation' Google account, grant it Viewer access to the GA properties you care about, and authorize the connector with that account. The token never expires unless the account password changes or the OAuth grant is revoked.
Two hosts in one adapter: tools transparently call either Admin (admin endpoints) or Data (report endpoints) â paths are absolute URLs so the engine routes correctly. No extra config needed.
Property IDs: GA4 properties are 9-12 digit numeric IDs (NOT the measurement ID G-XXXXXXXX, NOT the Universal Analytics view ID). Find them via ga4_get_account_summaries (the first call you should make) or in the GA admin UI under Property Settings â Property details.
Reports â runReport body shape:
dimensions: array of{name: 'pagePath'}â see https://ga.dev/api/data/v1/dimensions for the full list (~190 built-in).metrics: array of{name: 'sessions'}â see https://ga.dev/api/data/v1/metrics (~80 built-in).dateRanges: array of{startDate: '2025-01-01', endDate: 'today'}.startDateacceptsYYYY-MM-DD,today,yesterday, orNdaysAgo.dimensionFilter/metricFilter: optional Filter expressions.limit(default 10k, max 250k),offset,orderBys.
Realtime: runRealtimeReport looks at the last 30 minutes. Only a subset of dimensions/metrics work here (those with realtime in their docs).
Funnel reports: runFunnelReport is in v1alpha â uses a multi-step funnel definition. See instructions in tool description.
Quotas:
- Data API: 200k requests/day per project, 5k tokens/hour, 25k tokens/day. Token cost depends on report complexity â see https://ga.dev/api/data/v1/quotas.
- Admin API: 1500 requests/hour per project, 100k/day.
- 429 â exponential backoff (engine handles retry on quota errors).
Out of scope here: BigQuery export, GTM (Tag Manager) â separate APIs, would be a sibling adapter.
ããªãã® AI 㯠Google Analytics 4 ãã 2 ã¯ãªãã¯å ã
ã³ãã¯ã¿ãŒãã€ã³ã¹ããŒã«ãè³æ Œæ å ±ã貌ãä»ããAI ã«è³ªåã7 æ¥éç¡æãã¯ã¬ãžããã«ãŒãäžèŠã