google-analytics-gtm-mcp
Provides tools for interacting with Google Analytics 4: running standard and realtime reports, managing custom dimensions and metrics, key events, audiences, and Measurement Protocol API secrets, and sending events.
Provides tools for managing Google Tag Manager resources: listing accounts, containers, workspaces, tags, triggers, and variables, creating/updating/deleting tags, triggers, and variables, and creating and publishing container versions.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@google-analytics-gtm-mcppull last 28 days of users and conversions by channel"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
google-analytics-gtm-mcp
One Model Context Protocol (MCP) server for Google Analytics 4 and Google Tag Manager, with both read and write access. Connect it to Claude (or any MCP client) and, in natural language, pull GA4 reports, manage measurement configuration, build remarketing audiences, and edit and publish GTM tags, triggers, and variables — all with your own Google credentials. No third-party service, no subscription.
A single Google Cloud service account powers both surfaces: grant it access in Google Analytics and in Tag Manager, point one environment variable at its key, and you get 40 tools across the two products from one server entry.
Features
Google Analytics 4 — read
List accounts and properties, property details, and data streams
Run GA4 reports (
run_report) and realtime reports (run_realtime_report)List custom dimensions, custom metrics, key events (conversions), and audiences
Google Analytics 4 — write
Create and archive custom dimensions; create custom metrics
Create key events (conversions)
Create and archive audiences (remarketing lists you can share to Google Ads)
Create / list / delete Measurement Protocol API secrets
Send events via the Measurement Protocol (with a
validate=Truemode that checks a payload without ingesting it)
Google Tag Manager — read
List accounts, containers, workspaces, tags, triggers, and variables
Get a single tag; list container versions; get the live (published) version
Google Tag Manager — write
Create, update, and delete tags, triggers, and variables
Create a container version from a workspace
Publish a version to live (guarded by
confirm=true)
Related MCP server: mcp-site-analyst
Requirements
Python 3.10+ (the MCP SDK requires it)
A Google Cloud project and a service account with a JSON key
The service account granted access on your GA4 account/property and your GTM account/container
Google setup (one time)
In the Google Cloud Console, create (or pick) a project.
Enable three APIs for that project: Google Analytics Data API, Google Analytics Admin API, and Tag Manager API.
Create a service account and download a JSON key for it. Note its email (
...@your-project.iam.gserviceaccount.com).In Google Analytics → Admin → Account (or Property) access management, add that email as a user — Editor if you want write access, Viewer/Analyst for read-only.
In Tag Manager → Admin → User Management (at the account and/or container level), add the same email — grant Publish (container permission) if you want to create and publish versions, or Read for read-only.
That's it — no OAuth consent screen, no token refresh. The service account authenticates directly.
Install
Using uv (recommended — it manages an isolated Python for you):
git clone https://github.com/burhan29ee/google-analytics-gtm-mcp.git
cd google-analytics-gtm-mcp
uv venv --python 3.12 .venv
uv pip install --python .venv/bin/python -e .Or with pip:
python3 -m venv .venv && source .venv/bin/activate
pip install -e .Configure your MCP client
Point the server at your service-account key with the GOOGLE_APPLICATION_CREDENTIALS environment variable, then add it to your client. For Claude Desktop, edit claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json; Windows: %APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"google-analytics-gtm": {
"command": "/absolute/path/to/google-analytics-gtm-mcp/.venv/bin/python",
"args": ["-m", "google_analytics_gtm_mcp.server"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account-key.json"
}
}
}
}Restart the client. You should be able to ask things like "list my GA4 properties," "pull last 28 days of users and conversions by channel," "create a remarketing audience of everyone who fired generate_lead in the last 60 days," or "list the tags in my GTM container and show me the live version."
Tool reference
Google Analytics 4
Tool | Type | What it does |
| read | List accounts and their properties |
| read | Property name, time zone, currency, industry |
| read | Web/app streams and their measurement IDs |
| read | GA4 report by metrics/dimensions/date range |
| read | Realtime report (last ~30 min) |
| read | Custom dimensions on a property |
| write | Create a custom dimension |
| write | Archive a custom dimension |
| read | Custom metrics on a property |
| write | Create a custom metric |
| read | Key events (conversions) |
| write | Mark an event as a conversion |
| read | Audiences on a property |
| write | Create an audience of users who fired an event |
| write | Archive an audience |
| read | MP API secrets for a stream |
| write | Create an MP API secret |
| write | Delete an MP API secret |
| write | Send an event via the Measurement Protocol |
Google Tag Manager
Tool | Type | What it does |
| read | Show the service-account identity, scopes, and visible accounts |
| read | List GTM accounts |
| read | List containers in an account |
| read | List workspaces in a container |
| read | List tags in a workspace |
| read | List triggers in a workspace |
| read | List variables in a workspace |
| read | Get a single tag by id |
| read | List container version headers |
| read | Get the live (published) version |
| write | Create a tag from a JSON resource |
| write | Update an existing tag |
| write | Delete a tag ( |
| write | Create a trigger |
| write | Update a trigger |
| write | Delete a trigger ( |
| write | Create a variable |
| write | Update a variable |
| write | Delete a variable ( |
| write | Freeze a workspace into a new version |
| write | Publish a version to live ( |
Development
pip install -e ".[dev]"
ruff check .
pytest -qSee CONTRIBUTING.md for the full workflow.
Security
The service-account key is a credential — treat it like a password. Never commit it (the .gitignore blocks key files), grant the service account the least access it needs in each product, and rotate the key if it's ever exposed. GTM write tools that affect a live container (gtm_delete_*, gtm_publish_version) require confirm=true. See SECURITY.md for details and how to report a vulnerability.
Notes
The
mcpdependency is pinned to>=1.2,<2. The 2.0 SDK reorganized its API and removedmcp.server.fastmcp, which this server uses.GA4 audiences use the GA4 Admin v1alpha API; the rest of GA4 uses the stable v1beta and Data APIs. GTM uses the Tag Manager v2 API.
This is an independent open-source project and is not affiliated with or endorsed by Google.
License
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceMCP server for Google Tag Manager and GA4, enabling tag management, consent auditing, workspace versioning, and analytics reporting through natural language.18302MIT
- FlicenseAqualityDmaintenanceAn MCP server that provides Google Analytics and Search Console data as tools for AI assistants, enabling natural language queries for web analytics, SEO performance, and site insights.13
- AlicenseBqualityAmaintenanceMCP server providing 32 tools for Google Search Console and Google Analytics 4, enabling search analytics, URL inspection, indexing, and cross-platform analysis via natural language.438MIT
- Alicense-qualityBmaintenanceAutomates Google Analytics 4 and Google Tag Manager setup, management, and health monitoring with blueprints, multi-environment support, and MCP tools for AI agents.MIT
Related MCP Connectors
Security-first WordPress MCP server. 129 tools for Claude, ChatGPT, Gemini. Free on wp.org.
Hosted MCP with 91 agent tools: X, domains, SEO, Maps, Trends, Search, YouTube, TikTok, and more.
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/burhan29ee/google-analytics-gtm-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server