Google Analytics MCP Server avatar

Google Analytics MCP Server

Pricing

Pay per usage

Go to Apify Store
Google Analytics MCP Server

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

CQ

Maintained by Community

Actor stats

1

Bookmarked

9

Total users

2

Monthly active users

a day ago

Last modified

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:

  1. Authenticates with the service-account JSON you provide (credentialsJson).
  2. Sets the target GA4 property (propertyId).
  3. Executes the tool call(s) passed in toolCall and/or toolCalls.
  4. Pushes results to the dataset: one mcp_server_info record at the start, one tool_result record per tool call, and one session_stats record 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
}
}
}
FieldRequiredDescription
credentialsJsonFor all data toolsService-account JSON key, raw or base64-encoded. Marked secret.
propertyIdFor all tools except ga_info and ga_propertiesNumeric GA4 property ID (e.g. 123456789). A properties/ prefix is stripped automatically.
toolCallOne of toolCall / toolCallsA single { "name": ..., "arguments": {...} } object.
toolCallsOne of toolCall / toolCallsAn 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)

ToolArguments (defaults)Returns
ga_run_reportdimensions (req), metrics (req), start_date=30daysAgo, end_date=today, limit=100, order_by, descending=true, dimension_filterdata rows of the requested dimension/metric values, plus row_count and total_rows
ga_realtimemetrics=["activeUsers"], dimensions=[]Real-time rows for the requested metrics/dimensions
ga_top_pagesstart_date, end_date, limit=20, metric=screenPageViewsTop pages by pagePath/pageTitle with the chosen metric, sessions, averageSessionDuration
ga_traffic_sourcesstart_date, end_date, limit=20sessionSource/sessionMedium with sessions, totalUsers, newUsers, bounceRate
ga_user_demographicsdimension=country (one of country, city, language, region), start_date, end_date, limit=20totalUsers, sessions, newUsers by the chosen dimension
ga_device_breakdownstart_date, end_datedeviceCategory with totalUsers, sessions, screenPageViews, averageSessionDuration
ga_conversionsstart_date, end_date, limit=20eventName with eventCount, totalUsers, eventCountPerUser
ga_date_comparisonmetrics (req), period1_start=30daysAgo, period1_end=today, period2_start=60daysAgo, period2_end=31daysAgoperiod_1, period_2 values and a changes map with the % difference per metric
ga_funnelpages (optional list), start_date, end_dateWithout pages: top page paths by views. With pages: per-page views/users as ordered funnel steps
ga_propertiesnoneAccessible GA4 properties (via the Admin API): property_id, display_name, account, time_zone, currency, industry. Needs credentials; no propertyId required
ga_metadatanoneA sample of available dimensions and metrics (up to 50 each) plus full dimensions_count/metrics_count for the property
ga_infononeServer 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

  1. Create a Google Cloud project.
  2. Enable the Google Analytics Data API and the Google Analytics Admin API (the Admin API is required for ga_properties).
  3. Create a service account and download its JSON key.
  4. In GA4 Admin → Property Access Management, add the service-account email with at least Viewer access to the property.
  5. Pass the JSON key as credentialsJson (raw JSON or base64) and your numeric property ID as propertyId.

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 (only ga_info works).
  • Requires GA4 property access. The service account must be granted access to the target property, and propertyId must be set for all tools except ga_info and ga_properties.
  • Read-only. Uses the analytics.readonly scope; 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_metadata returns a sample only — up to 50 dimensions and 50 metrics — while the reported counts reflect the full totals.
  • ga_properties needs 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.