# Google Analytics MCP server: setup guide for Claude, Gemini and Cursor

> Connect GA4 to Claude, Gemini CLI or Cursor with Google's official Analytics MCP server: credentials, config files, useful prompts and common setup errors.

**In short:**
- Google's official Analytics MCP server (analytics-mcp) runs locally and reads GA4 through the Admin and Data APIs.
- Enable both APIs, sign in with the analytics.readonly scope, then add pipx run analytics-mcp to Claude, Gemini or Cursor.
- It's read-only by default; write tools need --allow-write and the edit scope.

- URL: https://noxtag.com/google-analytics-mcp-setup/
- Category: AI + analytics
- Last updated: 2026-12-03
- Publisher: noxtag (https://noxtag.com)

Google publishes an official **Model Context Protocol (MCP) server for Google Analytics**. Once it's connected, an AI assistant like Claude, Gemini CLI or Cursor can list your GA4 properties, run reports and check your property configuration from a chat window. You don't have to export CSVs or click through Explorations.

This guide walks through the setup end to end, shows the config for each client, and covers the four mistakes behind almost every "it doesn't work" thread.

## What the Google Analytics MCP server actually does

The server runs **locally on your machine** and talks to two Google APIs on your behalf:

- **Google Analytics Admin API**: account and property details, Google Ads links, custom dimensions and metrics, annotations.
- **Google Analytics Data API**: standard reports, funnel reports and realtime reports.

Search for each in **APIs & Services → Library** and click **Enable** (1):

![Google Cloud console – API Library – Google Analytics Data API](https://noxtag.com/img/shot-gcp-analytics-data-api.png)

The tools it exposes to your AI client are:

| Group | Tools |
|---|---|
| Account and property info | `get_account_summaries`, `get_property_details`, `list_google_ads_links`, `list_property_annotations`, `create_property_annotation` |
| Reports | `run_report`, `run_funnel_report`, `get_custom_dimensions_and_metrics` |
| Realtime | `run_realtime_report` |

Two things to know before you start:

1. **It's read-only by default.** The only write tool (creating annotations) stays off unless you start the server with `--allow-write` *and* your credentials include the edit scope.
2. **Google labels it experimental.** It works well, but tool names and flags can change between releases, so check the [GitHub repo](https://github.com/googleanalytics/google-analytics-mcp) if something in this guide stops matching.

![How the Google Analytics MCP server connects your AI client to GA4](https://noxtag.com/img/ga-mcp-how-it-works.svg)
*Figure: How the Google Analytics MCP server works. How the Google Analytics MCP server connects your AI client to GA4.*

## Prerequisites

- **Python 3.10 or newer**
- **pipx** (or `uv`), which runs the server in its own isolated environment
- **The Google Cloud CLI (`gcloud`)**, used to create credentials
- **A Google Cloud project** where you can enable APIs
- **Viewer access (or higher)** on the GA4 properties you want to query

![The four setup steps at a glance](https://noxtag.com/img/ga-mcp-setup-steps.svg)
*Figure: Set up the GA4 MCP server in 4 steps. The four setup steps at a glance.*

## Step 1: Enable the two APIs

In the Google Cloud console, open your project and enable:

- **Google Analytics Admin API**
- **Google Analytics Data API**

If you skip this step, the server starts fine but every tool call fails with a `403 ... API has not been used in project` error. That's the most common setup failure.

## Step 2: Create credentials

The server uses **Application Default Credentials (ADC)** with the read-only Analytics scope: `https://www.googleapis.com/auth/analytics.readonly`. There are two ways to get them.

### Option A: sign in as yourself (best for one person)

Create an OAuth client of type **Desktop app** in your Cloud project and download its JSON file. Then run:

```bash
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_FILE
```

### Option B: impersonate a service account (best for teams and agencies)

Create a service account, add its email as a **Viewer** in GA4 (Admin → Property access management), then run:

```bash
gcloud auth application-default login \
  --impersonate-service-account=SERVICE_ACCOUNT_EMAIL \
  --scopes=https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform
```

Either way, `gcloud` prints a line like `Credentials saved to file: [/Users/you/.config/gcloud/application_default_credentials.json]`. **Copy that path.** You need it in the next step.

> **Agency tip:** use the service-account route. You add one email to each client's GA4 property, you don't share personal logins, and removing access is one click when an engagement ends.

## Step 3: Add the server to your AI client

### Claude Code

```bash
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-mcp
```

### Claude Desktop, Cursor and other JSON-configured clients

Add this inside the `mcpServers` block of the client's config file:

```json
{
  "mcpServers": {
    "analytics-mcp": {
      "command": "pipx",
      "args": ["run", "analytics-mcp"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
        "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
      }
    }
  }
}
```

### Gemini CLI

Use the same block in `~/.gemini/settings.json`, then run `/mcp` inside Gemini CLI. You should see `analytics-mcp` listed with its tools.

> **Project ID variable:** Google's README mentions `GOOGLE_CLOUD_PROJECT` in its text but uses `GOOGLE_PROJECT_ID` in the config example. If the server complains about a missing project, set both to the same value.

Restart the client after editing its config. MCP servers load at startup.

## Step 4: Test it with three prompts

Start simple and work up:

1. **"What GA4 accounts and properties can you see?"** This calls `get_account_summaries`. If it returns your properties, credentials and APIs are working.
2. **"For property 123456789, show sessions, engaged sessions and key events by default channel group for the last 28 days."** This exercises `run_report`.
3. **"What custom dimensions and metrics are defined on property 123456789?"** This is the start of a quick configuration audit.

## Prompts that are actually useful

![The kind of questions that would take ten minutes of clicking in GA4](https://noxtag.com/img/mcp-prompts.svg)
*Figure: Prompts that pay off with the GA4 MCP server. The kind of questions that would take ten minutes of clicking in GA4.*


The real value isn't "how many users yesterday". It's questions that would take ten minutes of clicking:

- **"Compare purchase revenue by device category this month vs. last month, and flag any category that dropped more than 20%."**
- **"Build a funnel: view_item → add_to_cart → begin_checkout → purchase for the last 30 days, split by device. Where is the biggest drop?"**
- **"List event names with fewer than 10 events in the last 90 days."** Rare events are usually typos or broken tags. `add_to_cart` and `add-to-cart` firing side by side is a classic.
- **"Show me (not set) landing pages by session source for the last 14 days."** A spike in `(not set)` landing pages usually means a session started without a `page_view`, often because of consent or tag sequencing problems.
- **"Which Google Ads accounts are linked to this property?"** Handy when you inherit an account and nobody knows what's connected.

## Troubleshooting

![The five errors behind almost every failed setup](https://noxtag.com/img/mcp-errors.svg)
*Figure: GA4 MCP errors and their fixes. The five errors behind almost every failed setup.*


**"API has not been used in project … or it is disabled."**
Enable both Analytics APIs (Step 1) in the *same* project as your credentials, then wait a minute or two.

**"Request had insufficient authentication scopes."**
Your ADC file was created without the analytics scope, often by an earlier plain `gcloud auth application-default login`. Re-run the login command from Step 2 with `--scopes`.

**The server shows up but has no tools, or times out on start.**
Run `pipx run analytics-mcp` in a terminal to see the real error. Usually it's a Python version below 3.10 or pipx missing from the PATH the client uses. On macOS, apps launched from the Dock don't inherit your shell's PATH, so use the full path to `pipx` in `command`.

**"User does not have sufficient permissions for this property."**
The identity behind your credentials (you or the service account) needs at least Viewer access on that GA4 property. Account-level access works too.

**Numbers don't match the GA4 interface.**
Check the date range and time zone first. Then look for thresholding: GA4 hides rows with small user counts when Google signals is on, and the API applies the same rules. Explorations and standard reports can also disagree because of sampling and different session definitions. That isn't the MCP server's fault.

## Security notes before you roll this out

![Four rules before you connect client properties](https://noxtag.com/img/mcp-security.svg)
*Figure: Before you roll out the GA4 MCP server. Four rules before you connect client properties.*


- **Keep it read-only** unless you have a reason not to. The read-only scope can't change your property even if a prompt asks it to.
- **Treat the credentials file like a password.** Anyone with it can read every property that identity can see.
- **Watch for data leaving your machine.** Report rows go into the AI model's context. For most aggregate reporting that's fine. Check your company's AI policy before pulling anything user-level.
- **Use one service account per client** if you're an agency, so access is easy to audit and revoke.

> **Further reading:** [What is a data layer? A practical guide for GA4 and GTM](https://noxtag.com/data-layer-guide/)

## Frequently asked questions

### What is the Google Analytics MCP server?

The Google Analytics MCP server is Google's official, open-source Model Context Protocol server (analytics-mcp). It lets AI assistants like Claude, Gemini and Cursor read GA4 data and property settings through the Google Analytics Admin and Data APIs.

### Is the Google Analytics MCP server read-only?

Yes, by default. It uses the analytics.readonly scope and can't change your settings. Write tools, such as creating property annotations, only work if you start the server with --allow-write and your credentials include the analytics.edit scope.

### Why does the Google Analytics MCP server return a 403 error?

A 403 'API has not been used in project' error means the Google Analytics Admin API or Data API isn't enabled in the Google Cloud project behind your credentials. Enable both APIs in the same project and wait a minute before retrying.

### Can I use the Google Analytics MCP server with Claude?

Yes. In Claude Code, run claude mcp add analytics-mcp with your credentials path and project ID, followed by -- pipx run analytics-mcp. In Claude Desktop, add the same command to the mcpServers section of the config file and restart.

## Where MCP fits in a measurement stack

An MCP server makes it fast to *ask questions* of GA4. It doesn't make the data any more correct. If your events are duplicated, your consent setup drops sessions, or your ecommerce data layer sends the wrong values, the AI will confidently summarize wrong numbers.

That's why we pair MCP-assisted analysis with a proper implementation check. Our [GA4 & GTM audit](https://noxtag.com/audit/) covers tags, the data layer, consent mode and ecommerce events, so the answers your AI gives you are worth acting on.

---
Source: https://noxtag.com/google-analytics-mcp-setup/ · Need help with GA4 or GTM? https://noxtag.com/audit/
