How do you connect Claude to GA4 via MCP?

Most GA4 workflows involve logging in, clicking through menus, exporting data, and then interpreting it separately. Connecting Claude to GA4 through MCP (Model Context Protocol) cuts that process down to a single conversation. This guide covers exactly what you need to set up the connection, authenticate it properly, and start asking questions against your live analytics data.
Contributed by
SaaS Hackers
No items found.
No items found.
Blog

Quick Answer: You can connect Claude to GA4 by setting up a Google Analytics MCP server that gives Claude direct access to your property data. The process takes 20-30 minutes and requires a Google Cloud service account, the GA4 Data API enabled, and a local MCP configuration file. Once connected, Claude can run queries, surface trends, and generate weekly insight reports from your live analytics data.

Pulling insights from GA4 usually means logging in, clicking through reports, exporting CSVs, and then trying to make sense of the numbers. That process is slow and easy to skip.

Connecting Claude to GA4 via MCP (Model Context Protocol) changes that. You give Claude direct access to your analytics data and ask it questions in plain English. This guide covers the full setup: authentication, running your first queries, and a set of weekly insight prompts built 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 data sources and tools. Instead of copying data into a chat window, Claude reads it directly from the source.

For GA4 specifically, MCP means Claude can query your analytics property in real time. You can ask "which acquisition channels drove the most trial signups last month?" and get an answer pulled from your actual data, not a generic template.

Why this matters for B2B SaaS teams:

  • No more manual report exports
  • Analysts and non-analysts can both get answers fast
  • Claude can spot patterns across multiple dimensions simultaneously
  • Weekly reporting becomes a prompt, not a project

What You Need Before You Start

Before touching any configuration files, make sure you have the following ready:

  • A Google Analytics 4 property with data flowing in
  • A Google Cloud account (free tier works)
  • Claude Desktop installed on your machine
  • Node.js installed (version 18 or higher)
  • Basic comfort with terminal commands and editing JSON files

If you are using Claude via the API rather than Claude Desktop, the MCP server setup differs. This guide covers the Claude Desktop path.

Step 1: Create a Google Cloud Project

  1. Go to console.cloud.google.com
  2. Click Select a project at the top, then New Project
  3. Name it something recognisable, for example "Claude GA4 MCP"
  4. Click Create and wait for the project to provision

If you already have a Google Cloud project connected to your GA4 property, you can use that one instead. Creating a separate project keeps permissions clean.

Step 2: Enable the Google Analytics Data API

  1. Inside your new project, navigate to APIs & Services > Library
  2. Search for "Google Analytics Data API"
  3. Click the result and hit Enable

This is the API that allows programmatic access to GA4 report data. Without it, the MCP server cannot read your property.

Step 3: Create a Service Account

A service account is a non-human Google identity that the MCP server uses to authenticate with GA4. This is the right approach for local tooling because it does not require you to re-authenticate with OAuth every session.

  1. Go to APIs & Services > Credentials
  2. Click Create Credentials > Service Account
  3. Give it a name like "claude-ga4-reader"
  4. Click Create and Continue
  5. On the role step, skip adding a role (you will grant access at the GA4 level instead)
  6. Click Done

Next, generate a key for this service account:

  1. Click on your new service account in the list
  2. Go to the Keys tab
  3. Click Add Key > Create New Key
  4. Choose JSON and click Create
  5. A JSON file downloads to your machine. Keep this file safe. It is your authentication credential.

Step 4: Grant the Service Account Access to Your GA4 Property

The service account exists in Google Cloud, but GA4 does not know about it yet. You need to add it as a user inside GA4.

  1. Open analytics.google.com
  2. Go to Admin > Property Access Management
  3. Click the + button and select Add users
  4. Enter the service account email address (it looks like claude-ga4-reader@your-project.iam.gserviceaccount.com)
  5. Set the role to Viewer
  6. Click Add

Viewer access is enough for read-only queries. Do not grant Editor or Admin unless you have a specific reason.

Step 5: Note Your GA4 Property ID

You need your GA4 property ID to tell the MCP server which property to connect to.

  1. In GA4, go to Admin > Property Settings
  2. Copy the Property ID (a numeric value, for example 123456789)

Keep this handy for the next step.

Step 6: Install the Google Analytics MCP Server

Open your terminal and run:

npm install -g @modelcontextprotocol/server-google-analytics

If that package is not available in your npm registry, the community-maintained option used by most teams is the one from insightfulpipe.com. Check that resource for the exact package name and any version updates, as the MCP ecosystem moves fast.

Alternatively, you can clone and run a local MCP server directly:

git clone https://github.com/[repo-name]/ga4-mcp-server
cd ga4-mcp-server
npm install

Step 7: Configure Claude Desktop to Use the MCP Server

Claude Desktop uses a configuration file to know which MCP servers to load. You need to edit this file to add your GA4 server.

Find the config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Open the file in any text editor. If it does not exist, create it.

Add your GA4 MCP server configuration:

{
  "mcpServers": {
    "google-analytics": {
      "command": "node",
      "args": ["/path/to/your/ga4-mcp-server/index.js"],
      "env": {
        "GA4_PROPERTY_ID": "123456789",
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json"
      }
    }
  }
}

Replace the placeholders:

  • /path/to/your/ga4-mcp-server/index.js with the actual path to the server file
  • 123456789 with your real GA4 property ID
  • /path/to/your/service-account-key.json with the path to the JSON key you downloaded in Step 3

Save the file.

Step 8: Restart Claude Desktop and Test the Connection

  1. Fully quit Claude Desktop (do not just close the window)
  2. Reopen it
  3. Look for a tools or MCP indicator in the interface (this confirms the server loaded)

Test the connection with a simple prompt:

"Using the GA4 MCP tool, show me sessions and users for the last 7 days."

If Claude returns real numbers from your property, the connection is working. If you get an error, check that:

  • The file paths in your config are absolute, not relative
  • The service account email was added to GA4 with Viewer access
  • The Google Analytics Data API is enabled in your Cloud project
  • Node.js is accessible from the path Claude uses to run commands

Running Your First GA4 Queries with Claude

Once connected, you can ask Claude to run GA4 queries using plain language. Claude translates your request into the GA4 Data API format, fetches the data, and returns a structured answer.

Basic queries to start with:

  • "What were my top 10 landing pages by sessions last month?"
  • "Show me the conversion rate by traffic source for the last 30 days"
  • "Which countries sent the most users in Q2?"
  • "What is the average session duration broken down by device category?"

For B2B SaaS specifically:

  • "How many users completed the trial signup event in the last 14 days, broken down by acquisition channel?"
  • "What is the drop-off rate between the pricing page and the signup page?"
  • "Show me returning user sessions versus new user sessions week over week for the last 8 weeks"

Claude can also combine dimensions and metrics in ways the standard GA4 interface makes awkward. Ask it to cross-reference acquisition source with engagement rate, or to compare two date ranges side by side. If organic search is a key growth channel for your team, it can also help to benchmark your reporting workflows against how leading SaaS teams work with specialised B2B SaaS SEO agencies.

Weekly Insight Prompts for B2B SaaS Teams

One of the highest-value uses of this integration is replacing your manual weekly analytics review with a structured prompt routine. Run these every Monday morning.

Prompt 1: Traffic and Acquisition Summary

"Pull last week's sessions, new users, and returning users. Break sessions down by channel group. Compare to the previous week and flag any channel that changed by more than 15% in either direction."

Prompt 2: Conversion Funnel Check

"Show me the completion rate for [your key conversion event] last week versus the week before. Then show me the top 3 pages users visited before completing that event."

Prompt 3: Content Performance

"Which 5 pages had the highest engaged sessions last week? Which 5 had the lowest engagement rate with more than 100 sessions? Summarise what that pattern suggests."

Prompt 4: Paid vs Organic Comparison

"Compare sessions and conversion events from organic search versus paid search over the last 4 weeks. Show week-by-week. Identify the trend direction for each."

Prompt 5: Anomaly Detection

"Look at daily sessions for the last 30 days. Identify any days where sessions were more than 20% above or below the 30-day average. List the dates and the percentage deviation."

Save these as a text file or Claude Project prompt. Running all five takes under 5 minutes and gives you a complete weekly picture without opening GA4 once. If you want to turn those insights into a broader demand gen plan, it may also be useful to compare approaches across B2B SaaS performance marketing agencies, B2B SaaS PPC agencies, or B2B SaaS content marketing agencies.

Common Setup Errors and How to Fix Them

Error: "MCP server failed to start" Check that the file path in your claude_desktop_config.json is correct and absolute. Relative paths do not work.

Error: "Permission denied on GA4 property" The service account email has not been added to GA4, or it was added to the wrong property. Double-check the email address matches exactly.

Error: "Google Analytics Data API not enabled" Go back to Google Cloud Console and confirm the API is enabled for the correct project. The service account and the API must be in the same project.

Error: "Invalid property ID" Confirm you are using the numeric Property ID from GA4 Admin, not the Measurement ID (which starts with G-).

FAQs

What is the Google Analytics MCP server for Claude? The Google Analytics MCP server is a local process that connects Claude Desktop to your GA4 property via the Google Analytics Data API. It uses the Model Context Protocol standard so Claude can read your analytics data directly and answer questions about it without any manual data export.

Do I need coding skills to connect Claude to GA4? You need basic comfort with terminal commands and editing a JSON file. The process does not require writing code, but you do need to run npm commands, create a service account in Google Cloud, and edit a configuration file. Most B2B SaaS operators with any technical background can complete it in under 30 minutes.

Is it safe to connect Claude to my GA4 data? Yes, when set up correctly. The service account uses read-only Viewer access, so Claude cannot modify your GA4 property or data. The credentials stay on your local machine inside the config file. Do not commit your service account JSON key to any public repository.

Can I use this with Claude via API instead of Claude Desktop? The MCP server approach described here is designed for Claude Desktop. If you are using the Claude API directly, you can pass GA4 data as tool call results in your own application, but that requires custom development rather than the config file approach above.

How is this different from using Windsor.ai to connect GA4 to Claude? Windsor.ai is a no-code connector that syncs GA4 data to Claude without any local setup. The MCP approach described here runs locally, gives you more control over what data Claude accesses, and does not require a paid third-party service. The trade-off is that the MCP setup takes more time to configure initially.

What GA4 data can Claude access through MCP? Claude can access any data available through the GA4 Data API, including sessions, users, events, conversions, engagement metrics, traffic sources, page-level data, and custom dimensions or events you have configured in your property. It cannot access raw event-level data from BigQuery exports through this method.

No items found.
AI

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.

SaaS Hackers character line up

More from the blog