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.
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.
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

Nine tools.
Four read account and property information:
get_account_summarieslists what your login can seeget_property_detailsreturns one property’s settingslist_google_ads_linksshows which Ads accounts are linkedget_custom_dimensions_and_metricsreturns your custom definitions so the model can query them by name
Three run reports:
run_reportis the standard Data API report with any dimensions, metrics, date range and filterrun_funnel_reportdoes step by step funnelsrun_realtime_reportis 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.
--allow-write and grant the analytics.edit scope. I leave it off.What you need
| Requirement | Where it comes from |
|---|---|
| A GA4 property | You have this already |
| A Google Cloud project | console.cloud.google.com, free |
| Two APIs enabled | Google Analytics Data API and Google Analytics Admin API, in that project |
| Python 3.10 or newer, and pipx | Your machine |
| The gcloud CLI | For Application Default Credentials |
| A client that runs local servers | Claude 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

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.
--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.
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

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.
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:
- “How many users did we have yesterday, and from which channels?” One
run_reportwith date, sessionDefaultChannelGroup and activeUsers. - “Top ten products by revenue last week.” itemName and itemRevenue, sorted.
- “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.
- “Which landing pages had the highest bounce rate with more than 500 sessions?” A report with a metric filter. The model writes the filter.
- “Show me the checkout funnel for the last 30 days.”
run_funnel_reportwith view item, add to cart, begin checkout, purchase. - “What is happening on the site right now?” Realtime report.
- “Which campaigns are sending traffic that does not convert?” Source, medium, campaign against sessions and conversions, sorted by the gap.
- “List my custom dimensions.” So you know what the model can query before you ask about, say, customer type.
- “Which Google Ads accounts are linked to this property?” Useful before step 7, because unlinked accounts are why Ads traffic shows as (not set).
- “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.
When it does not connect

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.
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.
Stuck at step 4
Thirty minutes on a call
Screen shared, we get it connected and run the first report together.
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?
Is there an official Google Analytics MCP server?
How do I connect GA4 to Claude?
Does the Google Analytics MCP server work with Claude on the web?
What is an MCP server?
Can the GA4 MCP server change my Analytics settings?
What credentials does the Google Analytics MCP server need?
Why does Claude show the analytics-mcp server as failed?
Is it safe to connect Google Analytics to an AI model?
Is the Google Analytics MCP server free?
Can I connect Google Ads the same way?
Part of AI automation and MCP and Tracking and analytics, where every guide on the subject is listed in reading order.
Get new posts in your inbox
Occasional notes on Shopify, paid ads, and what I learn. No spam.
Thanks. Check your inbox to confirm.
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.