How do you connect Claude to GA4?

Quick Answer: You can connect Claude to GA4 by setting up a Google Analytics MCP (Model Context Protocol) server that authenticates via a Google Cloud service account. Once configured, Claude can query your live GA4 data directly, run analysis, and surface insights without you exporting a single CSV.
Pulling meaningful insights from GA4 normally means logging in, clicking through reports, exporting data, and then interpreting it yourself. That process is slow, repetitive, and easy to deprioritise.
With Claude and the Model Context Protocol, you give your AI assistant direct, authenticated access to your GA4 property. Ask it a question in plain English, get a structured answer backed by real data. This tutorial walks through the full setup: authentication, MCP configuration, and the weekly insight prompts that make this genuinely useful for B2B SaaS teams.
What Is MCP and Why Does It Matter for GA4?
MCP (Model Context Protocol) is an open standard that lets AI models like Claude connect to external tools and data sources through a defined interface. Instead of pasting data into a chat window, Claude connects directly to the source and queries it on demand.
For GA4 specifically, this means Claude can pull session data, conversion events, traffic sources, and funnel metrics in real time. No manual exports. No stale spreadsheets. Just live data, queried conversationally.
What You Need Before You Start
Before touching any configuration, make sure you have:
- A Google Analytics 4 property with data flowing in
- A Google Cloud project (free to create at console.cloud.google.com)
- Claude Desktop installed (available at claude.ai/download)
- Node.js installed on your machine (v18 or later)
- Admin access to your GA4 property
If you are missing any of these, sort them first. The setup breaks at authentication if your permissions are incomplete.
Step 1: Create a Google Cloud Project and Enable the Analytics API
- Go to console.cloud.google.com
- Click New Project, give it a name (e.g. "Claude GA4 MCP"), and click Create
- With your project selected, go to APIs and Services > Library
- Search for Google Analytics Data API and click Enable
- Also enable the Google Analytics Admin API if you want Claude to access property configuration data
Both APIs need to be active. Enabling just one is a common mistake that causes authentication errors later.
Step 2: Create a Service Account
A service account is how Claude authenticates with Google. It acts as a non-human user with defined permissions on your GA4 property.
- In Google Cloud Console, go to IAM and Admin > Service Accounts
- Click Create Service Account
- Give it a descriptive name (e.g. "claude-ga4-reader") and click Create and Continue
- For the role, select Viewer at the project level, then click Done
- Click on your new service account, go to the Keys tab
- Click Add Key > Create New Key, select JSON, and download the file
Store that JSON file somewhere safe on your machine. You will reference its file path in the MCP configuration. Do not commit it to version control.
Step 3: Grant the Service Account Access to Your GA4 Property
The service account exists in Google Cloud, but GA4 does not automatically trust it. You need to add it as a user inside GA4.
- Open analytics.google.com
- Go to Admin > Property Access Management
- Click the + button to add a user
- Paste in the service account email address (it looks like
claude-ga4-reader@your-project.iam.gserviceaccount.com) - Set the role to Viewer
- Click Add
The service account now has read access to your property data. Viewer access is sufficient for all reporting queries.
Step 4: Find Your GA4 Property ID
You need your GA4 Property ID for the MCP configuration.
- In GA4, go to Admin > Property Settings
- Copy the Property ID (a numeric string, e.g.
123456789)
Keep this handy. It goes directly into your MCP config file.
Step 5: Install and Configure the GA4 MCP Server
The GA4 MCP server is an open-source package that handles the connection between Claude and the Analytics Data API.
Install via npm:
npm install -g @modelcontextprotocol/server-google-analytics
Alternatively, you can use the ga4-mcp-server package maintained by the community. Check the current npm registry for the most actively maintained version, as this ecosystem is moving fast.
Configure Claude Desktop:
Open your Claude Desktop configuration file. On Mac, this lives at:
~/Library/Application Support/Claude/claude_desktop_config.json
On Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add the following to your mcpServers block:
{
"mcpServers": {
"google-analytics": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-google-analytics"],
"env": {
"GA4_PROPERTY_ID": "YOUR_PROPERTY_ID_HERE",
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/your/service-account-key.json"
}
}
}
}
Replace YOUR_PROPERTY_ID_HERE with the numeric ID from Step 4, and update the credentials path to match where you saved your JSON key file.
Save the file and restart Claude Desktop.
Step 6: Verify the Connection
Once Claude Desktop restarts, look for the MCP tools icon in the chat interface. If the server connected successfully, you will see Google Analytics listed as an available tool.
Test it with a simple prompt:
"How many sessions did my website have in the last 7 days?"
Claude should return a direct answer pulled from your GA4 property. If you get an error, check:
- The service account email is added to GA4 with Viewer access
- The JSON credentials path in your config is the absolute path, not relative
- Both APIs are enabled in Google Cloud Console
- Your GA4 Property ID is numeric only (no "properties/" prefix)
Weekly Insight Prompts for B2B SaaS Teams
The connection is only valuable if you use it regularly. Here are seven prompts built for B2B SaaS analytics workflows. Run these weekly to keep your team informed without manual reporting. If organic search is a core acquisition channel for you, this fits neatly alongside broader B2B SaaS SEO support and measurement workflows.
Traffic and Acquisition
"Which traffic sources drove the most new users last week, and how did their engagement rates compare?"
This surfaces channel-level quality, not just volume. High sessions from a source with a 90% drop-off rate is a signal worth catching early.
"Show me organic search sessions for the last 4 weeks as a trend. Is the direction up or down?"
Trend visibility in 10 seconds. Useful for flagging SEO shifts before they become problems.
Conversion and Funnel
"What was the conversion rate for [your key event, e.g. 'demo_request'] last week compared to the week before?"
Replace the event name with whatever your primary conversion action is in GA4. Claude will pull the comparison directly.
"Which landing pages had the highest conversion rates for [key event] in the last 30 days?"
Identifies your best-performing entry points. Useful for paid media targeting decisions, especially if you are also benchmarking against B2B SaaS PPC agency approaches.
Product and Engagement
"What were the top 5 pages by engaged sessions last week? Exclude the homepage."
Engaged sessions (30 seconds or more, with interaction) are a better signal than raw pageviews for SaaS content. Teams investing heavily in educational content often pair this with a stronger B2B SaaS content marketing strategy.
"How many users completed [event name] more than once in the last 30 days?"
Tracks repeat engagement with a key product action. Useful for understanding activation depth.
Weekly Summary
"Give me a weekly performance summary: sessions, new users, top traffic source, and [primary conversion event] count for the last 7 days versus the previous 7 days."
One prompt, one structured summary. Copy it into your weekly standup doc or Slack update. For teams trying to connect reporting to broader pipeline outcomes, it can also help to compare these readouts with your wider B2B SaaS performance marketing reporting cadence.
What Claude Can and Cannot Do with GA4 Data
Claude can:
- Query sessions, users, pageviews, events, and conversions by date range
- Break down data by dimension (source, medium, device, country, page)
- Calculate percentage changes between periods
- Identify trends and surface anomalies in plain language
- Run multiple queries in sequence to build a fuller picture
Claude cannot:
- Access raw user-level data (GA4 aggregates by design)
- Modify your GA4 configuration or tracking setup
- Access Google Ads data unless you have linked your accounts and the MCP server supports it
- Replace a full analytics platform for complex attribution modelling
For B2B SaaS teams running weekly reporting cycles, the query capabilities cover 80% of what you actually need.
Troubleshooting Common Setup Issues
"Permission denied" errors: The service account email is not added to the GA4 property, or it was added with insufficient access. Re-check Step 3.
"API not enabled" errors: One or both APIs in Google Cloud are still disabled. Go back to Step 1 and confirm both are active.
Claude does not show the MCP tool: The config file has a JSON syntax error, or the file path to your credentials is wrong. Validate your JSON at jsonlint.com before restarting.
Data returns zeros: Your GA4 Property ID is wrong, or the property has no data for the requested date range. Confirm the ID in GA4 Admin settings.
FAQs
Q: Do I need to pay for anything to connect Claude to GA4? A: The Google Analytics Data API has a free quota of 200,000 tokens per project per day, which is more than sufficient for weekly reporting queries. Claude Desktop requires an Anthropic subscription. There are no additional costs specific to this MCP setup.
Q: Is my GA4 data safe when connected to Claude via MCP? A: The MCP server runs locally on your machine. Your GA4 data is queried directly via the authenticated service account and is not stored or transmitted beyond your local Claude session. The service account has read-only Viewer access, so Claude cannot modify your GA4 property or data.
Q: Can I connect multiple GA4 properties to Claude? A: Yes. You can configure multiple MCP server entries in your Claude Desktop config file, each pointing to a different GA4 Property ID and service account. Name each server entry distinctly so Claude can reference the correct property when you specify it in your prompts.
Q: What is the best way to use Claude with GA4 for B2B SaaS reporting? A: The most effective approach is to build a set of 5-7 standard weekly prompts that map to your key metrics (traffic, conversions, engagement), run them on a fixed schedule, and use Claude's output as the basis for your team reporting. This removes the manual data-gathering step entirely and keeps reporting consistent week to week.
Q: Does this work with Claude.ai in the browser, or only Claude Desktop? A: MCP server connections currently require Claude Desktop. The browser version of Claude.ai does not support custom MCP server configurations at this time.
Find a B2B SaaS Expert
We've collected a directory of B2B SaaS experts and agencies that we've reviewed and categorised based on service and specialism for your review.


