Google Analytics MCP Server
Pricing
Pay per usage
Google Analytics MCP Server
MCP server for Google Analytics 4. AI agents can run custom reports, check real-time data, analyze traffic sources, demographics, devices, conversions, and compare date ranges. 12 tools with GA4 Data API.
Pricing
Pay per usage
Rating
0.0
(0)
Developer
CQ
Maintained by CommunityActor stats
1
Bookmarked
9
Total users
2
Monthly active users
a day ago
Last modified
Categories
Share
An Apify Actor that exposes 12 Google Analytics 4 (GA4) tools for AI assistants and automation workflows. You call one or more tools through the Actor input; the Actor executes each call against your GA4 property and writes the result to the run's dataset.
Built on the Google Analytics Data API v1beta (reporting and real-time) and the Google Analytics Admin API (property discovery), using service-account authentication.
How it works
Each run:
- Authenticates with the service-account JSON you provide (
credentialsJson). - Sets the target GA4 property (
propertyId). - Executes the tool call(s) passed in
toolCalland/ortoolCalls. - Pushes results to the dataset: one
mcp_server_inforecord at the start, onetool_resultrecord per tool call, and onesession_statsrecord at the end.
This Actor runs the requested tools once per run and then exits — it is not a persistent, live MCP endpoint. The "MCP tool" set is invoked through the Actor input.
Input
{"credentialsJson": "{ ... service account JSON ... }","propertyId": "123456789","toolCall": {"name": "ga_top_pages","arguments": {"start_date": "30daysAgo","end_date": "today","limit": 10}}}
| Field | Required | Description |
|---|---|---|
credentialsJson | For all data tools | Service-account JSON key, raw or base64-encoded. Marked secret. |
propertyId | For all tools except ga_info and ga_properties | Numeric GA4 property ID (e.g. 123456789). A properties/ prefix is stripped automatically. |
toolCall | One of toolCall / toolCalls | A single { "name": ..., "arguments": {...} } object. |
toolCalls | One of toolCall / toolCalls | An array of tool-call objects executed in sequence. |
If credentialsJson is missing the run still completes, but every data tool returns an authentication error (ga_info still works).
Tools (12)
| Tool | Arguments (defaults) | Returns |
|---|---|---|
ga_run_report | dimensions (req), metrics (req), start_date=30daysAgo, end_date=today, limit=100, order_by, descending=true, dimension_filter | data rows of the requested dimension/metric values, plus row_count and total_rows |
ga_realtime | metrics=["activeUsers"], dimensions=[] | Real-time rows for the requested metrics/dimensions |
ga_top_pages | start_date, end_date, limit=20, metric=screenPageViews | Top pages by pagePath/pageTitle with the chosen metric, sessions, averageSessionDuration |
ga_traffic_sources | start_date, end_date, limit=20 | sessionSource/sessionMedium with sessions, totalUsers, newUsers, bounceRate |
ga_user_demographics | dimension=country (one of country, city, language, region), start_date, end_date, limit=20 | totalUsers, sessions, newUsers by the chosen dimension |
ga_device_breakdown | start_date, end_date | deviceCategory with totalUsers, sessions, screenPageViews, averageSessionDuration |
ga_conversions | start_date, end_date, limit=20 | eventName with eventCount, totalUsers, eventCountPerUser |
ga_date_comparison | metrics (req), period1_start=30daysAgo, period1_end=today, period2_start=60daysAgo, period2_end=31daysAgo | period_1, period_2 values and a changes map with the % difference per metric |
ga_funnel | pages (optional list), start_date, end_date | Without pages: top page paths by views. With pages: per-page views/users as ordered funnel steps |
ga_properties | none | Accessible GA4 properties (via the Admin API): property_id, display_name, account, time_zone, currency, industry. Needs credentials; no propertyId required |
ga_metadata | none | A sample of available dimensions and metrics (up to 50 each) plus full dimensions_count/metrics_count for the property |
ga_info | none | Server version, stats, tool count, auth status, current property_id. Works without credentials |
Every result is an object with a success flag; on failure it contains an error message instead of data.
Setup
- Create a Google Cloud project.
- Enable the Google Analytics Data API and the Google Analytics Admin API (the Admin API is required for
ga_properties). - Create a service account and download its JSON key.
- In GA4 Admin → Property Access Management, add the service-account email with at least Viewer access to the property.
- Pass the JSON key as
credentialsJson(raw JSON or base64) and your numeric property ID aspropertyId.
The Actor requests the read-only scope https://www.googleapis.com/auth/analytics.readonly.
Common queries
Top 10 pages this month:
{"name": "ga_top_pages", "arguments": {"limit": 10, "start_date": "30daysAgo"}}
Traffic sources last week:
{"name": "ga_traffic_sources", "arguments": {"start_date": "7daysAgo"}}
Month-over-month comparison:
{"name": "ga_date_comparison", "arguments": {"metrics": ["totalUsers", "sessions", "screenPageViews"],"period1_start": "30daysAgo", "period1_end": "today","period2_start": "60daysAgo", "period2_end": "31daysAgo"}}
Limitations
- Requires Google service-account credentials. Without a valid
credentialsJson, the run completes but every data tool returns an authentication error (onlyga_infoworks). - Requires GA4 property access. The service account must be granted access to the target property, and
propertyIdmust be set for all tools exceptga_infoandga_properties. - Read-only. Uses the
analytics.readonlyscope; it cannot modify GA4 configuration or data. - Google API quotas and rate limits apply. Large or frequent requests may be throttled or return quota errors from the Analytics Data API.
- Data availability, sampling, and latency. GA4 reports can be sampled, thresholded (low-volume rows withheld), and delayed; real-time and standard reports may not reflect the most recent events.
ga_metadatareturns a sample only — up to 50 dimensions and 50 metrics — while the reported counts reflect the full totals.ga_propertiesneeds the Admin API enabled and lists only properties the service account can access.- Not a persistent MCP endpoint. Each run executes the tool call(s) supplied in the input and then exits; there is no long-running/Standby server connection.
- Errors are surfaced, not fatal. API or network failures are returned as
{"success": false, "error": ...}in the tool result rather than failing the whole run.

