Connect Google Analytics 4 to Claude: The Official GA4 MCP Server, Step by Step

Does Google Analytics have an MCP server? Yes. Google ships an official one for GA4, open source, free, read only by default, and it works with Claude Desktop, Claude Code, Gemini CLI and Cursor. Not with Claude on the web, which cannot launch a local process.

Google ships an official MCP server for Google Analytics 4. Fifteen minutes of setup and you can ask your property questions in plain English from Claude: how many users yesterday, which products sold, which channels drove them, where the funnel leaks. This is the full setup for Claude Code, Claude Desktop, Cursor and Gemini CLI, every tool the server exposes, the PATH problem that breaks most first installs, and what to ask once it works.

I pull numbers out of GA4 constantly, and most of those pulls are the same five reports with different date ranges. Connecting the property to Claude through MCP has turned most of that into typed questions. This is the setup guide I wish had existed when I did it, kept current as Google updates the server.

đź”’
Before anything else: the official server is read only unless you deliberately switch on its one write tool. It can run reports and read property details. It cannot create events, edit settings, or touch your configuration. That is the right default, and it is why connecting a production property to a model is a reasonable thing to do.

What MCP is, in one paragraph

MCP, the Model Context Protocol, is a standard for letting an AI assistant call tools in outside systems. A server exposes one system as a set of tools, and the assistant decides when to call them. The Google Analytics server exposes GA4 reports. Your job is authentication and wiring. After that, the model does the part you used to do by hand: picking dimensions and metrics, setting the date range, reading the table. The longer version for a non technical reader is what is an MCP server, for store owners.

đź’ˇ
The server is Google's own. Open source at googleanalytics/google-analytics-mcp, published on PyPI as analytics-mcp, and it runs locally on your machine under your credentials. Nothing is hosted by a third party.

What the GA4 MCP server exposes

What the GA4 MCP server exposes: nine tools, eight read only, covering account summaries, property details, Google Ads links, custom dimensions and metrics, standard reports, funnel reports, realtime reports and annotations, plus one write tool that adds a dated annotation and is off unless started with allow-write

Nine tools.

Four read account and property information:

  • get_account_summaries lists what your login can see
  • get_property_details returns one property’s settings
  • list_google_ads_links shows which Ads accounts are linked
  • get_custom_dimensions_and_metrics returns your custom definitions so the model can query them by name

Three run reports:

  • run_report is the standard Data API report with any dimensions, metrics, date range and filter
  • run_funnel_report does step by step funnels
  • run_realtime_report is what is happening right now

Two handle annotations, the dated notes on the property timeline: one reads them and one, create_property_annotation, writes them.

đź’ˇ
The annotation writer is the only tool that changes anything, and it is off by default. You have to start the server with --allow-write and grant the analytics.edit scope. I leave it off.

What you need

RequirementWhere it comes from
A GA4 propertyYou have this already
A Google Cloud projectconsole.cloud.google.com, free
Two APIs enabledGoogle Analytics Data API and Google Analytics Admin API, in that project
Python 3.10 or newer, and pipxYour machine
The gcloud CLIFor Application Default Credentials
A client that runs local serversClaude Code, Claude Desktop, Cursor or Gemini CLI

Budget 15 minutes if the Cloud project already exists, 25 if you are starting from nothing.

The setup

The five step GA4 MCP install: enable both the Analytics Data and Admin APIs, install the server with pipx, authenticate read only, register it with your client, then verify. If it fails at registration the client cannot find the command and needs the full path

1. Enable the APIs. In your Cloud project, enable the Google Analytics Data API and the Google Analytics Admin API. Both, not one. The Data API runs reports, the Admin API lets the server discover your accounts and properties. Missing the second one is the reason the server connects and then cannot find any property.

2. Install pipx, if you do not have it. On a Mac, brew install pipx then pipx ensurepath. On Windows, py -m pip install --user pipx then py -m pipx ensurepath. Open a new terminal afterwards so the path change applies.

3. Authenticate. The server reads Application Default Credentials, so one gcloud command does it:

gcloud auth application-default login \
  --scopes=https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform

A browser opens, you sign in with the Google account that has access to the GA4 property, and the credentials land on disk. The command prints a line that says where: “Credentials saved to file” followed by a path. Copy that path; you need it in the next step. Note the scope: read only, deliberately.

đź’ˇ
For a shared or scheduled machine, skip the personal login. The same command accepts --impersonate-service-account with a service account granted Viewer on the property. That is the setup I use on the machine that runs scheduled reports.

4. Register it with your client.

For Claude Code, one command, with the two values from above:

claude mcp add analytics-mcp \
  --scope user \
  -e "GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json" \
  -e "GOOGLE_PROJECT_ID=your-cloud-project-id" \
  -- pipx run analytics-mcp

For Claude Desktop, open the config file (Settings, Developer, Edit Config, which opens claude_desktop_config.json) and add:

{
  "mcpServers": {
    "analytics-mcp": {
      "command": "pipx",
      "args": ["run", "analytics-mcp"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/credentials.json",
        "GOOGLE_PROJECT_ID": "your-cloud-project-id"
      }
    }
  }
}

Cursor takes the same JSON in its MCP settings. Gemini CLI takes it in ~/.gemini/settings.json. Restart the client after saving.

5. Verify. In Claude Code, claude mcp list should report the server as connected. In any client, ask: “List my Google Analytics properties.” If it comes back with your property names, you are done.

đź’ˇ
The failure that gets almost everyone: the server shows as failed because the client cannot find pipx. Clients launch servers outside your shell setup, so your PATH does not apply. Fix it by using the full path in the config, /opt/homebrew/bin/pipx on an Apple Silicon Mac or /Users/you/.local/bin/pipx elsewhere, instead of the bare command. Run which pipx in a terminal to get it.

Which client to use

Which client to use for the GA4 MCP server: Claude Code with one command, Claude Desktop through its config file, Gemini CLI through settings.json, Cursor through its MCP settings, and Claude on the web not supported because it cannot launch local processes

The server runs on your machine, so the client has to be able to start a local process. Claude Code, Claude Desktop, Cursor and Gemini CLI all can. Claude on the web cannot, and Google does not ship a hosted version. Third party hosts exist that put the server behind a URL you can add as a remote connector in the browser; the tradeoff is that your Google credentials then live with them.

đź’ˇ
For a store, the desktop app is the sensible answer. My own split: Claude Desktop for questions I ask while working, Claude Code when the answer needs to end up in a file or a sheet, because it can write the result out. The weekly Shopify report runs on the same idea without a chat window at all.

What to ask it

The tool surface is small and it covers the questions that make up most day to day GA4 usage. Ten I use, with what the model does underneath:

  1. “How many users did we have yesterday, and from which channels?” One run_report with date, sessionDefaultChannelGroup and activeUsers.
  2. “Top ten products by revenue last week.” itemName and itemRevenue, sorted.
  3. “Compare organic sessions this month against the same days last month.” Two date ranges in one report, which is the kind of thing that takes four clicks and a mistake in the UI.
  4. “Which landing pages had the highest bounce rate with more than 500 sessions?” A report with a metric filter. The model writes the filter.
  5. “Show me the checkout funnel for the last 30 days.” run_funnel_report with view item, add to cart, begin checkout, purchase.
  6. “What is happening on the site right now?” Realtime report.
  7. “Which campaigns are sending traffic that does not convert?” Source, medium, campaign against sessions and conversions, sorted by the gap.
  8. “List my custom dimensions.” So you know what the model can query before you ask about, say, customer type.
  9. “Which Google Ads accounts are linked to this property?” Useful before step 7, because unlinked accounts are why Ads traffic shows as (not set).
  10. “Are there any annotations on the timeline for October?” Reads the notes your team left, which is the context the numbers do not carry.

The model translates each into the right dimensions and metrics, which quietly removes the worst part of GA4: remembering what anything is called in the API.

đź§Ş
Spot check the first week. The model will happily query a wrong date range or the wrong conversion event if you are vague. Check its first answers against the GA4 UI the way you would check a new analyst's work. Ask it to show the request it sent when a number looks off. Once you know where it is reliable, the checking stops being necessary.

When it does not connect

When the GA4 MCP server does not connect: server shows as failed means a PATH problem, 403 means the Google account has no access to the property, API not enabled means one of the two APIs is missing, wrong property means the model picked the wrong one, numbers differing from GA4 means a date range or filter the model chose, and credentials expired means run the gcloud login again

Six failures, in the order they happen to people:

  • Server shows as failed: PATH, covered above. Nine out of ten support threads.
  • 403 permission denied: the Google account you signed in with has no access to that property. Check Admin, Property access management, in GA4.
  • API has not been used in project: one of the two APIs is not enabled, or you enabled it in a different Cloud project from the one in GOOGLE_PROJECT_ID.
  • Wrong property or empty results: the model guessed. Ask it to list properties first and name the one you want in every prompt until it learns.
  • Numbers differ from the GA4 UI: nearly always a date range or a filter the model chose. Ask for the request.
  • Credentials expired: happens after a while. Run the gcloud login command again.

The limits, honestly

Local clients only. Covered above. If browser access matters more than keeping your credentials at home, a hosted wrapper is the trade.

Read only cuts both ways. Nothing can go wrong, and nothing can be done. Acting on findings is still your job.

The model sees what it reads. Property data flows into the conversation, and if your client keeps history, it stays there. For most stores that is fine. Decide before connecting if yours is different, and do not connect a property that holds anything you would not paste into a chat.

Quotas are generous but real. The Analytics Data API allows thousands of requests a day per property on the free tier. A person asking questions will not get near it. A script asking in a loop might.

It is labelled experimental. Google could change the tool names. The install and auth have not changed since launch, and when a tool is renamed the model adapts because it reads the tool list at startup.

The real value is the second server

On its own, the GA4 server saves you report clicks. The step change comes when Google Ads is connected in the same conversation, because then you can ask the reconciliation questions: where Ads reported conversions and GA4 purchase events disagree, by campaign, for the same period. That gap is where budgets quietly die, and the KPIs worth trusting depend on closing it.

đź’ˇ
Start the Google Ads developer token approval now. It takes days, and it is the slow part of connecting Google Ads to Claude. Add Shopify and Klaviyo and the four systems a store runs on answer the same question in one place.

Both Google servers are official and installable. When the system holding your data has none, you write your own. That is what I did for our point of sale: an MCP server for Clover POS, so the owner could ask about sales, items and tips without waiting on anyone to pull a report.

If you would rather have it wired for you

Analytics your team can ask questions of

GA4, Google Ads, Shopify and Klaviyo connected to Claude on your machines, read only, with the ten questions above tested against your own numbers. Scoped on a call first.

See what I build and what it costs

Stuck at step 4

Thirty minutes on a call

Screen shared, we get it connected and run the first report together.

Book a call


I’m Nikhil Sharma. I run data and operations engineering for a DTC brand and write about the systems underneath ecommerce. The wider set of tools is in AI workflows for a Shopify store.

Frequently asked questions

Can I connect Google Analytics to Claude?
Yes, through Google's official GA4 MCP server, in about fifteen minutes if you already have a Google Cloud project. It runs on your machine, so it works with Claude Desktop, Claude Code, Gemini CLI and Cursor, and not with Claude in a browser. Once connected you ask questions in plain English and Claude runs the Analytics Data API report behind them.
Is there an official Google Analytics MCP server?
Yes. Google maintains it at googleanalytics/google-analytics-mcp on GitHub and publishes it on PyPI as analytics-mcp. It uses the Analytics Data API for reports and the Admin API for account and property details. Google labels it experimental, and it has been stable in daily use for me since it shipped.
How do I connect GA4 to Claude?
Enable the Analytics Data API and Admin API in a Google Cloud project, install pipx, authenticate with gcloud auth application-default login using the read only analytics scope, then register the server with your client. In Claude Code that is one claude mcp add command with the credentials path and project ID as environment variables. In Claude Desktop it is a short block in claude_desktop_config.json. Fifteen minutes if the Cloud project already exists.
Does the Google Analytics MCP server work with Claude on the web?
Not directly. The server runs on your machine, and Claude on the web cannot launch local processes. Use Claude Desktop, Claude Code, Cursor or Gemini CLI. Third party hosted versions exist that work in a browser, with the tradeoff that your credentials live with the host.
What is an MCP server?
MCP, the Model Context Protocol, is a standard that lets an AI assistant call tools in outside systems. An MCP server exposes one system as a set of tools. The Google Analytics server exposes GA4 reporting, so an assistant like Claude can pull metrics, run reports and read property details on your behalf. The longer version for a non technical reader is in the what is an MCP server post on this site.
Can the GA4 MCP server change my Analytics settings?
Effectively no. Eight of its nine tools are read only: reports, funnels, realtime, property details, custom definitions, Ads links and annotations. The one write tool adds a dated annotation to the property timeline, and it is disabled unless you start the server with --allow-write and grant the edit scope. It cannot create events, goals, audiences or change any setting.
What credentials does the Google Analytics MCP server need?
Application Default Credentials from the gcloud CLI, scoped to analytics.readonly, signed in as a Google account that has access to the GA4 property. No API key is needed. A service account with impersonation also works if you want it off a personal login.
Why does Claude show the analytics-mcp server as failed?
Almost always PATH. The client launches servers outside your shell setup, so pipx or analytics-mcp is not found. Put the full path to the binary in the config, usually under ~/.local/bin, and it connects. The other common cause is one of the two APIs not being enabled in the Cloud project.
Is it safe to connect Google Analytics to an AI model?
The server runs locally under your own credentials and is read only by default, so the risk is data exposure rather than damage. Whatever the model reads becomes part of the conversation. Treat it the way you would treat exporting a report and pasting it into a chat, because that is what it is.
Is the Google Analytics MCP server free?
Yes. The server is open source, the Google Cloud project costs nothing at this usage, and the Analytics APIs have a free daily quota that a person asking questions will not approach. You pay for the AI client you use it from.
Can I connect Google Ads the same way?
Yes. Google ships a separate official MCP server for Google Ads. The setup is longer because of the developer token approval, and having both connected in one conversation is where the real value shows up: you can ask where Ads conversions and GA4 purchases disagree, by campaign.

Part of AI automation and MCP and Tracking and analytics, where every guide on the subject is listed in reading order.

Nikhil Sharma

Nikhil Sharma

Nikhil Sharma runs data and operations for a DTC brand on Shopify and consults for Shopify brands on Meta and Google ads, conversion and AI automation. He writes case studies and implementation guides from accounts and systems he has run himself.

Book a call More about me