{
  "markdown": "# Google Analytics 4 MCP Server\n\n<!-- mcp-name: io.github.stucchi/google-analytics -->\n\nMCP server for Google Analytics 4 — create properties, configure data streams, manage conversions, and run reports via the Admin & Data APIs.\n\n## Setup (one-time, ~3 minutes)\n\n1. **Google Cloud Console** → [IAM & Admin → Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts)\n   - Create a service account (any name)\n   - Click it → Keys → Add Key → JSON → Download\n\n2. **Enable APIs** in your GCP project:\n   - [Google Analytics Admin API](https://console.cloud.google.com/apis/library/analyticsadmin.googleapis.com)\n   - [Google Analytics Data API](https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com)\n\n3. **GA4 Admin** → Property Access Management → Add the service account email (from the JSON) as **Editor**\n\n4. **Configure credentials** (pick one):\n   - **Option A** (recommended): Copy the JSON content into the `GA_CREDENTIALS` env var in your MCP config\n   - **Option B**: Save the file to `~/.google-analytics-4-mcp/credentials.json`\n\nDone. No browser flow, no consent screen, no tokens to refresh.\n\n## Installation\n\n### Claude Code\n\n```bash\nclaude mcp add google-analytics -e GA_CREDENTIALS='{\"type\":\"service_account\",...}' -- uvx google-analytics-4-mcp\n```\n\n### Claude Desktop\n\nAdd to `claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"google-analytics\": {\n      \"command\": \"uvx\",\n      \"args\": [\"google-analytics-4-mcp\"],\n      \"env\": {\n        \"GA_CREDENTIALS\": \"{\\\"type\\\":\\\"service_account\\\",\\\"project_id\\\":\\\"...\\\", ...}\"\n      }\n    }\n  }\n}\n```\n\n### From source\n\n```bash\ngit clone https://github.com/stucchi/mcp-google-analytics.git\ncd mcp-google-analytics\nuv run google-analytics-4-mcp\n```\n\n## Getting Started\n\n1. **Check auth**: Call `check_auth_status` to verify the service account is configured\n2. **List accounts**: Call `list_accounts` to see your GA4 accounts\n3. **Setup a property**: Use `create_property` → `create_web_data_stream` → `get_tracking_snippet`\n4. **Query data**: Use `run_report` with dimensions and metrics\n\n## Tools (23)\n\n### Auth\n\n| Tool | Description |\n|------|-------------|\n| `check_auth_status` | Verify service account is configured and valid |\n\n### Admin API\n\n| Tool | Description |\n|------|-------------|\n| `list_accounts` | List accessible GA4 accounts |\n| `list_properties` | List properties for an account |\n| `create_property` | Create a GA4 property |\n| `get_property` | Get property details |\n| `delete_property` | Soft-delete a property |\n| `list_data_streams` | List data streams |\n| `create_web_data_stream` | Create web stream → get Measurement ID |\n| `delete_data_stream` | Delete a data stream |\n| `get_tracking_snippet` | Generate gtag.js HTML snippet |\n| `list_key_events` | List conversion events |\n| `create_key_event` | Mark event as conversion |\n| `delete_key_event` | Remove conversion |\n| `list_custom_dimensions` | List custom dimensions |\n| `create_custom_dimension` | Create custom dimension |\n| `list_custom_metrics` | List custom metrics |\n| `create_custom_metric` | Create custom metric |\n| `list_google_ads_links` | List Google Ads links |\n| `create_google_ads_link` | Link Google Ads account |\n| `get_measurement_protocol_secret` | Get/create Measurement Protocol secret |\n\n### Data API\n\n| Tool | Description |\n|------|-------------|\n| `run_report` | Run report with dimensions, metrics, dates, filters |\n| `run_realtime_report` | Real-time active users and events |\n| `get_metadata` | List available dimensions and metrics |\n\n## Environment Variables\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `GA_CREDENTIALS` | — | Service Account JSON key content (copy-paste the entire JSON) |\n| `GA_CREDENTIALS_PATH` | `~/.google-analytics-4-mcp/credentials.json` | Alternative: path to the JSON key file |\n\n`GA_CREDENTIALS` takes priority over `GA_CREDENTIALS_PATH`.\n\n## Example Usage\n\n```\nYou: \"Set up Google Analytics for my website https://mcpadvisor.stucchi.consulting\"\n\nAssistant calls: list_accounts → create_property → create_web_data_stream → get_tracking_snippet\n\nResult: Property created with Measurement ID G-XXXXXXXXXX and ready-to-paste HTML snippet.\n```\n\n```\nYou: \"Show me the top 10 countries by sessions in the last 7 days\"\n\nAssistant calls: run_report(property_id=\"...\", dimensions=[\"country\"], metrics=[\"sessions\"], start_date=\"7daysAgo\", limit=10)\n```\n\n## License\n\nMIT\n",
  "bytes": 4436,
  "sha": "cbf0b41a797031f6648564894cd10200b839775b082b0373c015f0dc04f1a696",
  "repo_slug": "stucchi/mcp-google-analytics",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_stucchi_google_analytics_6b7cc5f8/readme"
}