# dhawalshah/google-analytics-mcp [Health: Active]

**Category:** 🎯 Marketing  
**Repository:** https://github.com/dhawalshah/google-analytics-mcp  
**GitHub Stars:** 0  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/dhawalshah-google-analytics-mcp

## Description
Google Analytics 4 MCP server with local STDIO and shared team Cloud Run modes, realtime visitor counts, metadata discovery, and funnel analysis.

## Tools
Capabilities this server exposes over MCP:

- **list_properties** — List all accessible GA4 accounts and their properties
- **get_page_views** — Page views by path or any dimension for a date range
- **get_active_users** — Active user counts by date or any dimension
- **get_events** — Event counts by event name or any dimension
- **get_traffic_sources** — Sessions and users by source/medium
- **get_device_metrics** — Sessions and page views split by device category
- **get_realtime_users** — Active users in the last 30 minutes (Realtime API)
- **get_property_metadata** — List all valid dimensions and metrics for a property
- **run_funnel_report** — Multi-step funnel analysis — track drop-off across a user flow *(experimental, v1alpha)*
- **run_report** — Fully custom report — any GA4 metrics and dimensions

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/dhawalshah/google-analytics-mcp), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

```sh
git clone https://github.com/dhawalshah/google-analytics-mcp
```

2. Run:

```sh
cd google-analytics-mcp
```

3. Install:

```sh
pip install -r requirements.txt
```

4. Configure:

```sh
cp .env.example .env       # fill in values
```

5. Sign in:

```sh
python setup_local_auth.py
```

## Documentation

## What dhawalshah/google-analytics-mcp does

dhawalshah/google-analytics-mcp provides an MCP interface to Google Analytics 4. An MCP-compatible client can use it to inspect accessible accounts and properties, query common GA4 reporting dimensions, check current activity, discover valid metadata, and construct custom reports.

The reporting tools cover page views, active users, events, traffic sources, and device categories. Realtime queries return active users from the previous 30 minutes. `run_funnel_report` analyzes drop-off across multiple steps in a user flow and is marked experimental and v1alpha. `run_report` accepts arbitrary GA4 metric and dimension combinations, making it suitable when the predefined reports are not enough.

## How it works

Two deployment modes are available. Local STDIO runs `server.py` as a subprocess launched by the MCP client. Before using it, `setup_local_auth.py` opens a Google sign-in flow and saves the resulting token at `~/.config/google-analytics-mcp/token.json`. This mode does not require Cloud Run or Firestore.

Remote HTTP mode deploys the service to Cloud Run and exposes the MCP endpoint at `/mcp`. It implements the MCP authorization specification dated 2025-06-18 and provides OAuth metadata, dynamic client registration, and an authorization flow backed by Google OAuth. After authentication, the service issues its own opaque bearer token; Google credentials remain on the server and are associated with the authenticated user. Firestore stores the bearer tokens and per-user Google credentials.

## Setup and configuration

The prerequisites are Python 3.10 or newer, a GA4 property, and a Google Cloud project. The Google Analytics Data API and Google Analytics Admin API must be enabled. OAuth credentials use a web application client, with callback URLs configured for local authentication and, when applicable, the Cloud Run service.

Install the Python dependencies with `pip install -r requirements.txt`. Local mode requires `OAUTH_CONFIG_PATH` and `MCP_USER_EMAIL` in the MCP client configuration, followed by `python setup_local_auth.py`. Remote mode requires a public `BASE_URL`, a GCP project for Firestore, and either `GOOGLE_CLIENT_ID` plus `GOOGLE_CLIENT_SECRET` or `OAUTH_CONFIG_PATH`. `ALLOWED_DOMAINS` can restrict sign-in to selected email domains.

For remote use, deploy the service to Cloud Run, add its live `/auth/callback` URL to the Google OAuth client, and register `https://YOUR-SERVICE-URL.run.app/mcp` in the client. A Cloud Run secret is recommended for the Google client secret.

## Tools and capabilities

- `list_properties` discovers accessible GA4 accounts and properties.
- `get_page_views`, `get_active_users`, and `get_events` query core reporting data.
- `get_traffic_sources` reports sessions and users by source and medium.
- `get_device_metrics` breaks down sessions and page views by device category.
- `get_realtime_users` reads active users from the last 30 minutes.
- `get_property_metadata` lists valid dimensions and metrics.
- `run_report` builds custom GA4 reports.
- `run_funnel_report` measures multi-step user-flow drop-off experimentally.

## Limitations and notes

Access depends on the signed-in Google account's permissions on the GA4 property. External OAuth consent applications in testing mode require users to be added as test users. Remote deployments require Firestore and appropriate Cloud Run service-account access. The older `?user=email` URL approach is not used; authentication occurs through the OAuth flow.

_Full upstream README: https://allmcps.com/mcp/dhawalshah-google-analytics-mcp/readme_

