quest_ga4_mcp_server.exe
_
×

GA4 MCP Server: Connect Google Analytics to Your AI Agents

Google's official GA4 MCP server connects your Google Analytics data to Claude, ChatGPT or Gemini. Full 2026 guide: setup, tools, prompts and real limits.

ga4 mcp ai google-analytics guide

Since 2026, Google’s official GA4 MCP server has changed how you query Google Analytics: instead of opening a report, you ask a plain-English question to Claude, ChatGPT or Gemini, and the agent pulls the data straight from your GA4 property. No SQL, no dashboard to navigate. This guide explains what the server is, how to install it step by step, which tools it exposes, and where its real limits sit.

Why connect GA4 to an AI agent?

Querying GA4 is a daily point of friction: open the interface, pick the right exploration, set the dimensions, wait for it to render. For a simple question like “which channel converted best last week?”, the time spent inside the tool far exceeds the time spent thinking.

An AI agent wired to your data flips that ratio. You state the intent, the agent turns the question into an API call, retrieves the numbers and comments on them. The win is not only speed: it is the ability to chain follow-up questions (“and by device?”, “compare to last month”) without rebuilding a report every time.

That link between an AI model and your data runs through MCP.

MCP in two sentences

MCP (Model Context Protocol) is an open protocol that connects an AI model to external data sources and services. An “MCP server” exposes specific capabilities (read a property, run a report, query realtime data) that the agent can call on demand.

By 2026, MCP has become the de facto standard for wiring tools into an LLM. That is what makes a GA4 server usable the same way from Claude, Gemini, Cursor or any other compatible client.

What is Google’s official GA4 MCP Server?

Google publishes and maintains an open-source MCP server for Google Analytics, under the Apache 2.0 license, in the googleanalytics/google-analytics-mcp repository. It is a local server: it runs on your machine (the analytics-mcp Python package, launched with pipx) and relies on two official APIs, the Admin API and the Data API.

The key point: this server is read-only. It queries reports, lists your properties and retrieves metrics, but it cannot create a key event, change a configuration, or touch your settings. That design choice is reassuring when you point an agent at production data.

How it differs from Ask Advisor and Claude Code

Three approaches coexist for “talking” to GA4 with AI, and they do not target the same use case.

ApproachWhere it livesAccess typeBest for
Ask AdvisorNative, inside GA4Closed Google AI, GA4 dataGA4 users, quick in-app questions
GA4 MCP ServerLocal server, any MCP clientRead-only GA4 APIAnalysts and devs wanting any AI agent
Claude Code + BigQueryTerminal, GA4 exportRaw event-level SQLHeavy analysis, custom attribution

Ask Advisor, GA4’s native assistant, answers inside the interface but stays confined to the Google ecosystem and its preformatted replies. More in our take on GA4 Ask Advisor. The GA4 MCP Server, by contrast, lets you pick your agent (Claude, Gemini, ChatGPT) and fold it into your own workflows. For the heaviest event-level analysis, the Claude Code on GA4 and BigQuery approach stays more powerful, because it gives you raw SQL access to the export.

Prerequisites

Before installing, gather three things. First, an active GA4 property your account can access. Second, a Google Cloud project with the Admin API and the Data API enabled. Third, a compatible MCP client: Claude Code, Gemini CLI, ChatGPT or Cursor.

On permissions, the server only needs the read scope analytics.readonly. Never configure broader credentials than necessary: least privilege applies fully when an AI agent reaches into your data.

Step-by-step setup

Setup follows three main steps.

1. Configure Python

Install pipx, which runs the analytics-mcp package in an isolated environment. The server requires Python 3.10 or later. You do not need to clone the repository: pipx fetches the package published on PyPI.

2. Configure Google credentials

Enable the Admin API and the Data API in your Google Cloud project, then set up Application Default Credentials (ADC) with the analytics.readonly scope. In practice, a single gcloud auth application-default login command with the right scope does the job, whether with your user credentials or through service account impersonation. Note the path of the generated credentials file: you will need it in the next step.

3. Declare the server in your client

The last step is to register the server in your agent’s configuration. With Claude Code, one command is enough:

claude mcp add analytics-mcp \
  --scope user \
  -e "GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_CREDENTIALS_JSON" \
  -e "GOOGLE_PROJECT_ID=YOUR_PROJECT_ID" \
  -- pipx run analytics-mcp

With Gemini CLI, you instead add an analytics-mcp block to ~/.gemini/settings.json, under the mcpServers key, with the same environment variables. Once the agent restarts, type /mcp to confirm that analytics-mcp shows up in the list.

The exposed tools and sample prompts

The server exposes seven tools, split into three families.

ToolRole
get_account_summariesLists your GA4 accounts and properties
get_property_detailsReturns details about a property
list_google_ads_linksLists links to Google Ads accounts
run_reportRuns a standard report via the Data API
run_funnel_reportRuns a funnel report
get_custom_dimensions_and_metricsRetrieves custom dimensions and metrics
run_realtime_reportRuns a realtime report (last 30 minutes)

You never call these tools by hand: the agent picks the right one based on your question. In practice, that looks like prompts such as:

  • “What are my most frequent events over the last 180 days?”
  • “Compare this month’s organic sessions to last month’s, by device.”
  • “How many active users right now, and on which pages?” (the server then switches to run_realtime_report)
  • “Which custom dimensions and metrics are configured on my property?”

To go further on realtime questions and tracking AI sources, see our guide to tracking ChatGPT, Gemini and Claude traffic in GA4.

Limits and things to watch

The server is powerful, but three limits deserve your attention.

The first is scope: this is aggregated data, through the Data API, with official metric definitions but also with caps. To rebuild a raw user journey or custom attribution, you need the BigQuery export and SQL, as detailed in the 10 essential BigQuery queries for GA4.

The second is read-only: the server configures nothing. It answers questions; it does not automate your tracking.

The third is business judgment. An agent can misread a metric, confuse users with sessions, or mis-scope a date range. Critically reviewing the answers stays essential, especially before reporting a figure to a client or to leadership. That requirement ties into a broader theme: knowing how to measure what AI sees of you, which we cover in how to measure your brand’s visibility in AI answers.

When to use it, and when to choose something else

The GA4 MCP Server is the right call when you want to query GA4 in plain English, from the agent of your choice, for everyday questions and light reporting. It shines through its flexibility and fast setup.

Stick with Ask Advisor if you want an answer with nothing to install, directly inside the GA4 interface. Move to Claude Code on BigQuery as soon as you need raw event-level data, heavy analysis or custom attribution. The three approaches are complementary: the official MCP server fills exactly the gap between the closed native assistant and the full SQL toolkit.