Google Analytics MCP Server
A local MCP server for Google Analytics 4 that provides tools for SEO and paid reporting, enabling queries on organic and paid search performance, landing pages, channels, campaigns, and real-time data.
README
Google Analytics MCP
Local MCP server for Google Analytics 4. Wraps the GA4 Data API behind tools focused on SEO and Paid reporting.
Tools
| Tool | Purpose |
|---|---|
ga4_organic_search_performance |
SEO: Organic Search sessions/users/engagement/conversions by landing page, source, country, or device |
ga4_paid_search_performance |
Paid: Paid Search sessions/conversions/cost/CPC by campaign, landing page, keyword, or source |
ga4_all_paid_performance |
Paid: all paid channels (Search + Social + Video + Display) with cost and ROAS |
ga4_google_ads_performance |
Paid: Google Ads campaign × ad group × keyword (requires GA4 ↔ Google Ads link) |
ga4_landing_page_performance |
Top landing pages by sessions/engagement/conversions (optional channel filter) |
ga4_channel_performance |
Default channel group rollup |
ga4_campaign_performance |
Campaign × source × medium breakdown |
ga4_conversions_by_source |
Conversions and key events by source/medium/channel |
ga4_realtime_active_users |
Active users in last 30 min |
ga4_run_report |
Flexible escape hatch — any dimensions + metrics |
Setup
git clone https://github.com/ZLeventer/google-analytics-mcp-server.git
cd google-analytics-mcp-server
npm install
npm run build
Credentials
Copy .env.example to .env and fill in:
GA4_PROPERTY_ID— numeric property ID from GA4 Admin → Property Settings (e.g.123456789). Not the Measurement ID (G-XXXXXXX).GOOGLE_APPLICATION_CREDENTIALS— absolute path to the service account JSON key file.
Create the service account
- Go to console.cloud.google.com → pick/create a project
- APIs & Services → Library → enable Google Analytics Data API
- IAM & Admin → Service Accounts → Create service account (name it
ga4-mcpor similar) - On the created account → Keys → Add key → Create new key → JSON → download
- Save the JSON as
service-account.jsonin this directory (already in.gitignore) - In GA4 → Admin → Property Access Management, click + → paste the service account email (
ga4-mcp@project-id.iam.gserviceaccount.com) → assign Viewer
The Google SDK auto-reads GOOGLE_APPLICATION_CREDENTIALS — no code changes needed.
Install into Claude Code
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"
Or add to ~/.claude.json manually:
{
"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"
}
}
}
}
Restart Claude Code after install.
Date formats
All date args accept GA4 formats:
YYYY-MM-DD(e.g.2026-04-01)NdaysAgo(e.g.28daysAgo,90daysAgo)yesterday,today
Defaults: 28daysAgo → yesterday.
Verification
After credentials are in place:
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)))
'
If that returns rows, everything works. Expected errors:
GA4_PROPERTY_ID is not set— check.envPERMISSION_DENIED— service account isn't granted Viewer on the property403 Google Analytics Data API has not been used— enable the API in the GCP project
Roadmap
- [ ] Admin API tools (list custom dimensions, conversion events, audiences) once needed
- [ ] Search Console MCP as sibling server for rankings / impressions / CTR data (complements this one)
- [ ] Pair with Demandbase MCP to join GA4 traffic with firmographics (account-level attribution)
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.