Google Analytics MCP: how to connect GA4 to Claude and ChatGPT
A step by step guide to Google's own Google Analytics MCP server: the Cloud project, APIs and credentials it needs, the config for each client, the errors people hit, the hosted options if you would rather sign in, and prompts that work well.

How do I connect Google Analytics to Claude?
This guide sets up Google's official server, googleanalytics/google-analytics-mcp, step by step, then covers its common errors and the prompts that work best. You can ask it about sessions, conversions, revenue and engagement by channel, campaign, landing page or date. If you would rather sign in than manage a Cloud project, hosted GA4 MCP servers are covered after the setup.
Want GA4 in Claude or ChatGPT in two minutes, with no Cloud project? Connect Manifold's hosted GA4 MCP server and sign in with Google. Analytics calls cost 0 credits.
What is the Google Analytics MCP server?
A Google Analytics MCP server bridges your AI agent and the Google Analytics APIs. You ask a question in plain language about sessions, conversions or revenue, and your agent calls the right Analytics tools to fetch the data. Google introduces its server on the Google Analytics developer site and keeps the code and setup instructions in the GitHub README. The README lists seven tools:
- Account and property information:
get_account_summaries,get_property_details,list_google_ads_links - Core reports:
run_report,run_funnel_report,get_custom_dimensions_and_metrics - Realtime reports:
run_realtime_report
None of them change your GA4 settings. Google's developer page says the server handles read requests only.
There are three realistic ways to connect GA4 to your agent (people also call this a GA4 MCP):
- Google's official server: runs locally, needs a Google Cloud project and Application Default Credentials. Covered step by step below.
- Hosted vendors such as Stape, Composio and Windsor.ai: they run the server and handle the Google Cloud side, and you sign in with Google.
- Manifold: a hosted marketing MCP server with GA4 next to Search Console, SEO and AI visibility data.
The last two are covered briefly after the setup.
How to set up the official Google Analytics MCP server
1. Create a Google Cloud project
Open console.cloud.google.com, create a project, and note its project ID.
2. Enable both APIs
In your Cloud project, enable the Analytics Admin API and the Analytics Data API.
Without both, the server fails with "API not enabled" errors.
3. Set up credentials
Install pipx, then set up Application Default Credentials for a Google user who can see your GA4 property. The README asks for the Analytics scope plus the Cloud platform scope, using an OAuth client JSON you create in your Cloud project:
gcloud auth application-default login \
--scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform \
--client-id-file=YOUR_CLIENT_JSON_FILEThe command prints the path of the saved credentials file. Copy it, because every client config below needs it as GOOGLE_APPLICATION_CREDENTIALS. The README also shows a variant that impersonates a service account.
4. Check GA4 access
The credentials only see what that Google user (or service account) can see. If the account is not on the property yet, open Admin → Property access management in Google Analytics, click +, and add it with the Viewer role.
Without access, the server returns "Permission denied" on every Analytics call.
5. Test the server
pipx run analytics-mcpIf it starts without a credentials error, stop it and add it to your client.
6. Connect in Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"analytics-mcp": {
"command": "pipx",
"args": ["run", "analytics-mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
"GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
}
}
}
}Replace the two placeholders with your credentials path and Cloud project ID, then restart Claude. The server appears under Settings → Developer.
7. Connect in Claude Code
The README's command:
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-mcpThen run /mcp in Claude Code to check it is connected.
8. Connect in Gemini CLI
The official README shows the Gemini CLI config. Create or edit ~/.gemini/settings.json:
{
"mcpServers": {
"analytics-mcp": {
"command": "pipx",
"args": ["run", "analytics-mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
"GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
}
}
}
}9. Connect in Cursor
Add the same entry to ~/.cursor/mcp.json (or the project's .cursor/mcp.json):
{
"mcpServers": {
"analytics-mcp": {
"command": "pipx",
"args": ["run", "analytics-mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
"GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
}
}
}
}Does it work with ChatGPT?
Not directly. The official server runs locally, and ChatGPT and claude.ai on the web connect to MCP servers over public HTTPS, so they cannot reach it without a tunnel in front of it. Use a local client, or one of the hosted options below.
Troubleshooting the official server
Error: Credentials not found
Cause: No credentials set, or the wrong path.
Fix: Run the gcloud auth application-default login command above, and check that GOOGLE_APPLICATION_CREDENTIALS in your client config points to the file it saved.
Error: API not enabled
Cause: One or both Analytics APIs are not enabled in your Cloud project.
Fix: Enable the Analytics Admin API and Analytics Data API.
Error: Permission denied
Cause: The account (your user or the service account) lacks GA4 access.
Fix: Open Admin → Property access management in Google Analytics and add the email with Viewer role.
Error: Wrong property ID
Symptom: "Property not found" or empty results.
Fix: Ask the server for your account summaries first and copy the property ID from there. GA4 property IDs are numbers, written properties/123456789 in the API.
Who it fits
You already work with Google Cloud, know how to enable APIs and manage credentials, want Google's own code with no third party, and use a local client such as Claude Code, Claude Desktop, Gemini CLI or Cursor.
If you would rather not run it yourself
Hosted servers run the Google Cloud side for you. You sign in with Google instead of creating a project and credentials, and they work from ChatGPT and claude.ai on the web.
Stape says its GA4 server is free, Composio has a free tier, and Windsor.ai can put Search Console and Google Ads in the same conversation on a paid plan. Manifold's hosted GA4 MCP puts GA4 next to Search Console, SEO and AI visibility data on one server, with no realtime or funnel reports.
Check each one's pricing and limits before you commit.
What to ask once it's connected
Here are prompts for common Analytics jobs. They work with any of the servers above; the tool names are the official server's.
Sessions and conversions by channel
"Show sessions and key events by channel for property 123456789, last 28 days versus the previous 28 days."
Tools: run_report with sessions, key events and the default channel group, over two date ranges.
What you get: A table with current and previous sessions and conversions per channel (Organic Search, Direct, Paid Search, etc.), so you can see which channels grew or dropped.
Top landing pages for organic traffic
"What were the top 20 landing pages for organic traffic last month? Include sessions and bounce rate."
Tools: get_account_summaries to find the property, then run_report with sessions, bounce rate and landing page, filtered to the Organic Search channel.
What you get: A ranked list of your organic landing pages and how visitors behaved there.
Traffic drop diagnosis
"Sessions dropped 30% last week. Break it down by channel, then by landing page within organic. What changed?"
Tools: run_report with two date ranges (this week against last), first by channel, then by landing page filtered to organic.
What you get: Whether the drop was across all channels or one (for example organic fell while paid stayed flat), and which pages lost the most traffic.
Checkout funnel
"Show the funnel from view_item to add_to_cart to begin_checkout to purchase for last month, by device category."
Tools: run_funnel_report.
What you get: How many users reach each step and where they drop off, split by device.
Right now
"How many active users are on the site right now, and on which pages?"
Tools: run_realtime_report.
What you get: Live users by page, useful during a launch or a campaign send.
Conversions by campaign
"Show conversions by campaign last 30 days, sorted by conversion rate."
Tools: run_report with key events, sessions and campaign name. The agent then calculates conversion rate.
What you get: A ranked list of your campaigns and which converted best.
Revenue by source and medium
"What was revenue by source and medium last quarter?"
Tools: run_report with total revenue, source and medium.
What you get: A breakdown of where your revenue came from: organic, paid, social, email, referral, etc.
Custom dimensions and metrics
"List all custom dimensions and metrics for property 123456789."
Tools: get_custom_dimensions_and_metrics.
What you get: Your custom dimensions and metrics with their API names, ready to use in reports.
Pairing GA4 and Search Console
"Show GA4 organic sessions by landing page last 28 days, then Search Console clicks and impressions by page for the same dates. List pages with over 100 clicks but under 50 sessions."
This one needs Search Console on the same server, or a second server for it, because the official server sees only GA4.
What you get: Pages where Google delivered clicks but visitors bounced or did not register sessions, often because the page did not match the title and snippet promise.
Limits and gotchas
Report size
One Google Analytics Data API report takes at most 10 metrics and 9 dimensions. If you need more, split it into several reports.
Data thresholding
Google applies thresholding to GA4 reports when the number of users in a segment is too small, to protect user privacy. Small row counts may be withheld or aggregated.
Data settling
GA4 data can take a day or more to settle, so yesterday's numbers may still move. For totals you will compare later, end the range a couple of days back.
LLMs doing arithmetic
When you ask for a calculated metric like conversion rate or revenue per session, the agent fetches the raw numbers and calculates it. LLMs can make arithmetic mistakes on large numbers. Check the math yourself when it matters.
The official server sees only GA4
The official Google Analytics MCP server covers GA4 only. It cannot read Search Console or Bing. If you want those next to Analytics, use a hosted server that has both, such as Manifold's Google Search Console MCP server, which shares one Google connection with Analytics. For Search Console options on their own, see the best Google Search Console MCP servers.
Run this in your agent
Connect Manifold to Claude, ChatGPT or Cursor, then paste this prompt.
List my Analytics properties, then show sessions and key events by channel last 28 days versus the previous 28 days. Then pull Search Console clicks by page for organic traffic in the same period. Which pages had clicks but low sessions?



