Google Analytics MCP Server
Google Analytics MCP
Lokaler MCP-Server für Google Analytics 4. Kapselt die GA4 Data API in Tools, die auf SEO- und Paid-Reporting ausgerichtet sind.
Tools
Tool | Zweck |
| SEO: Sitzungen/Nutzer/Engagement/Conversions der organischen Suche nach Landingpage, Quelle, Land oder Gerät |
| Paid: Sitzungen/Conversions/Kosten/CPC der bezahlten Suche nach Kampagne, Landingpage, Keyword oder Quelle |
| Paid: Alle bezahlten Kanäle (Suche + Social + Video + Display) mit Kosten und ROAS |
| Paid: Google Ads Kampagne × Anzeigengruppe × Keyword (erfordert GA4 ↔ Google Ads Verknüpfung) |
| Top-Landingpages nach Sitzungen/Engagement/Conversions (optionaler Kanalfilter) |
| Standard-Kanalgruppen-Rollup |
| Aufschlüsselung nach Kampagne × Quelle × Medium |
| Conversions und Schlüsselereignisse nach Quelle/Medium/Kanal |
| Aktive Nutzer in den letzten 30 Min |
| Flexibler Ausweg — beliebige Dimensionen + Metriken |
Einrichtung
git clone https://github.com/ZLeventer/google-analytics-mcp-server.git
cd google-analytics-mcp-server
npm install
npm run buildAnmeldedaten
Kopieren Sie .env.example nach .env und füllen Sie die folgenden Felder aus:
GA4_PROPERTY_ID— numerische Property-ID aus GA4 Admin → Property-Einstellungen (z. B.123456789). Nicht die Measurement-ID (G-XXXXXXX).GOOGLE_APPLICATION_CREDENTIALS— absoluter Pfad zur JSON-Schlüsseldatei des Dienstkontos.
Dienstkonto erstellen
Gehen Sie zu console.cloud.google.com → Projekt auswählen/erstellen
APIs & Dienste → Bibliothek → Google Analytics Data API aktivieren
IAM & Verwaltung → Dienstkonten → Dienstkonto erstellen (nennen Sie es
ga4-mcpoder ähnlich)Beim erstellten Konto → Schlüssel → Schlüssel hinzufügen → Neuen Schlüssel erstellen → JSON → herunterladen
Speichern Sie das JSON als
service-account.jsonin diesem Verzeichnis (bereits in.gitignoreenthalten)Klicken Sie in GA4 → Admin → Property-Zugriffsverwaltung auf + → fügen Sie die E-Mail-Adresse des Dienstkontos ein (
ga4-mcp@project-id.iam.gserviceaccount.com) → weisen Sie die Rolle Betrachter zu
Das Google SDK liest GOOGLE_APPLICATION_CREDENTIALS automatisch ein — es sind keine Codeänderungen erforderlich.
In Claude Code installieren
claude mcp add google-analytics \
--env-file "/absolute/path/to/google-analytics-mcp-server/.env" \
-- node "/absolute/path/to/google-analytics-mcp-server/dist/index.js"Oder manuell zu ~/.claude.json hinzufügen:
{
"mcpServers": {
"google-analytics": {
"command": "node",
"args": ["/absolute/path/to/google-analytics-mcp-server/dist/index.js"],
"env": {
"GA4_PROPERTY_ID": "123456789",
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/google-analytics-mcp-server/service-account.json"
}
}
}
}Starten Sie Claude Code nach der Installation neu.
Datumsformate
Alle Datumsargumente akzeptieren GA4-Formate:
YYYY-MM-DD(z. B.2026-04-01)NdaysAgo(z. B.28daysAgo,90daysAgo)yesterday,today
Standardwerte: 28daysAgo → yesterday.
Überprüfung
Nachdem die Anmeldedaten hinterlegt sind:
node -e '
import("./dist/tools/reports.js").then(m =>
m.channelPerformance({ start_date: "7daysAgo", end_date: "yesterday", limit: 10 })
).then(r => console.log(JSON.stringify(r, null, 2)))
'Wenn dies Zeilen zurückgibt, funktioniert alles. Erwartete Fehler:
GA4_PROPERTY_ID is not set— prüfen Sie.envPERMISSION_DENIED— dem Dienstkonto wurde keine Betrachter-Rolle für die Property zugewiesen403 Google Analytics Data API has not been used— aktivieren Sie die API im GCP-Projekt
Roadmap
[ ] Admin-API-Tools (Auflistung benutzerdefinierter Dimensionen, Conversion-Ereignisse, Zielgruppen), sobald benötigt
[ ] Search Console MCP als ergänzender Server für Rankings / Impressionen / CTR-Daten (ergänzt diesen Server)
[ ] Kopplung mit Demandbase MCP, um GA4-Traffic mit Firmendaten (Account-basierte Attribution) zu verknüpfen
Available Tools
10 toolsga4_all_paid_performanceA
Paid: all paid channels (Search + Social + Video + Display + Other) broken down by channel × campaign × source × medium, with cost and ROAS.
Inputs: start_date, end_date, property_id, limit.
ga4_campaign_performanceB
Campaign × source × medium breakdown with sessions/conversions/revenue. Optional channel filter.
Inputs: start_date, end_date, property_id, limit, +1 more.
ga4_channel_performanceB
Default channel group rollup: sessions/users/conversions/revenue for Organic Search, Paid Search, Email, Direct, Referral, etc.
Inputs: start_date, end_date, property_id, limit.
ga4_conversions_by_sourceB
Conversions and key events broken down by session source × medium × channel group. Sorted by key events desc.
Inputs: start_date, end_date, property_id, limit.
ga4_google_ads_performanceA
Paid: Google Ads campaign × ad group × keyword performance (impressions, clicks, cost, CPC, conversions, ROAS). Requires Google Ads ↔ GA4 link.
Inputs: start_date, end_date, property_id, limit.
ga4_landing_page_performanceA
Top landing pages by sessions/engagement/conversions. Optional channel filter (e.g. 'Organic Search', 'Paid Search').
Inputs: start_date, end_date, property_id, limit, +1 more.
ga4_organic_search_performanceA
SEO: sessions/users/engagement/conversions for Organic Search traffic, broken down by landing page (default), source, country, or device.
Inputs: start_date, end_date, property_id, limit, +1 more.
ga4_paid_search_performanceB
Paid: sessions/conversions/cost/CPC for Paid Search traffic, broken down by campaign (default), landing page, keyword, or source.
Inputs: start_date, end_date, property_id, limit, +1 more.
ga4_realtime_active_usersB
Current active users (last 30 min) broken down by screen/page, country, device, or audience.
Inputs: property_id, breakdown, limit.
ga4_run_reportA
Flexible GA4 Data API runReport. Pass any dimensions + metrics. Use for custom reports the preset tools don't cover.
Inputs: dimensions (required), metrics (required), start_date, end_date, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a distinct area of GA4 data: all paid, specific channels, campaigns, conversions, landing pages, organic/paid search, realtime, and a generic report. No two tools have overlapping purposes that would cause confusion.
All tool names consistently follow the 'ga4_<descriptive_name>' format using snake_case. The naming pattern is predictable and uniform across the entire set.
10 tools is well within the ideal 3-15 range for a focused analytics server. Each tool serves a clear purpose, and the count feels neither excessive nor insufficient for covering core GA4 queries.
The set covers acquisition, behavior, conversions, and realtime analytics well. Minor gaps exist (e.g., user demographics, event details), but the flexible ga4_run_report tool allows agents to fill these gaps for custom reports.
Related MCP Connectors
Hosted MCP server for GA4, Google Ads and Search Console. Google OAuth, nothing to install.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
SEO MCP server for keyword research, SERP analysis, audits, and Search Console workflows.
SEO platform MCP server: GSC, Bing, Yandex, technical audits, local rank grids, and AI visibility.