# ga4 [Health: Active]

**Category:** 🎯 Marketing  
**Repository:** https://github.com/mharnett/mcp-ga4  
**GitHub Stars:** 1  
**npm Downloads (last month):** 1602  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/ga4

## Description
Google Analytics 4 MCP: reports, realtime data, custom dimensions, data streams.

## Tools
Capabilities this server exposes over MCP:

- **ga4_get_client_context** — Returns the active GA4 property ID and client name
- **ga4_run_report** — Run a standard GA4 report with dimensions, metrics, date range, and filters
- **ga4_realtime_report** — Query realtime data (last 30 minutes)
- **ga4_list_custom_dimensions** — List all custom dimensions for the property
- **ga4_create_custom_dimension** — Create a new custom dimension (write tool: hidden unless `GA4_MCP_WRITE=true`)
- **ga4_list_custom_metrics** — List all custom metrics for the property
- **ga4_list_data_streams** — List web/app data streams and their measurement IDs
- **ga4_send_feedback** — Submit feedback on a query result
- **ga4_suggest_improvement** — Suggest a new query pattern or improvement

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "ga4": {
    "command": "npx",
    "args": ["-y","mcp-ga4"],
    "env": {
      "GA4_PROPERTY_ID": "",
      "GOOGLE_APPLICATION_CREDENTIALS": "",
      "GA4_CLIENT_ID": "",
      "GA4_CLIENT_SECRET": "",
      "GA4_REFRESH_TOKEN": ""
    }
  }
}
```

**Requires environment variables:** `GA4_PROPERTY_ID`, `GOOGLE_APPLICATION_CREDENTIALS`, `GA4_CLIENT_ID`, `GA4_CLIENT_SECRET`, `GA4_REFRESH_TOKEN` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What the ga4 MCP server does

The ga4 MCP server exposes Google Analytics 4 reporting and property-management operations through MCP. It can run reports with selected dimensions, metrics, date ranges, and filters; query realtime activity from the previous 30 minutes; and return the active property ID and client name.

Property administration tools cover custom dimensions, custom metrics, and data streams. The server can list custom dimensions, create a new custom dimension, list custom metrics, and list web or app data streams with their measurement IDs. Two additional tools let users submit feedback about a query result or suggest a query pattern or improvement.

Typical report inputs can use absolute dates in `YYYY-MM-DD` format or supported relative values such as `today`, `yesterday`, `7daysAgo`, `30daysAgo`, and `90daysAgo`. Common analysis patterns include page views by page path, traffic sources, daily sessions, campaign performance, and device breakdowns.

## How it works

The ga4 MCP server uses Google’s Analytics Data API for reports and the Analytics Admin API for property-management operations. It is distributed as an npm package and can run through the `mcp-ga4` command or from a locally built repository. The project also uses resilience behavior based on the `cockatiel` package.

There are two configuration models. Single-property mode uses environment variables to select one GA4 property. Multi-client mode uses a `config.json` file to associate several property IDs with project directories; the active property is selected from the caller’s working directory. A configuration file can also provide a service-account credential path.

Standard reports may lag by 24–48 hours, while realtime queries cover only the latest 30 minutes. Creating custom dimensions changes the GA4 property and therefore requires an OAuth scope that permits editing when OAuth authentication is used.

## Setup and configuration

Install the npm package with `npm install mcp-ga4`, or clone the repository, install dependencies, and run its build command. The included setup utility can register the server with Claude Desktop and Claude Code. After changing the Claude Desktop configuration, fully quit and reopen the application; Claude Code sessions should be restarted.

Authentication supports either a service-account keyfile or user OAuth credentials. Service-account use requires granting the account access to the GA4 property, with at least Viewer access. OAuth use requires a Google desktop OAuth client, the Google Analytics Data API, and the relevant environment variables. If both credential families are configured, the keyfile takes precedence.

Keep `.mcp.json` and credential files private. The setup supports a `GA4_PROPERTY_ID` for single-property mode, while multi-client deployments can store property mappings in `config.json`.

## Tools and capabilities

- Identify the active GA4 property and configured client.
- Run filtered reports using dimensions, metrics, and date ranges.
- Query realtime GA4 activity.
- List or create custom dimensions.
- List custom metrics.
- List web and app data streams with measurement IDs.
- Submit query feedback and suggest improvements.

## Limitations and notes

The server requires valid Google credentials and access to the target GA4 property. Service-account authentication and OAuth are selected once at startup; a later API permission error is returned rather than triggering silent credential failover. Read-only OAuth scopes are sufficient for reporting, but creating custom dimensions requires the Analytics Admin API and an editing scope.

_Full upstream README: https://allmcps.com/mcp/ga4/readme_

