Google Tag Manager MCP Server
Provides tools for managing Google Tag Manager accounts, containers, workspaces, folders, tags, triggers, and variables, enabling programmatic interaction with GTM through the API.
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 Tag Manager MCP Serverlist all my GTM accounts"
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 Tag Manager MCP Server
Local Model Context Protocol (MCP) server for Google Tag Manager, allowing Claude to interact with your GTM accounts, containers, tags, triggers, and variables.
🚀 Quick Start
1. Clone and Install
git clone <repository-url>
cd gtm-mcp-server
npm install2. Setup Google Cloud Project and API
🌐 Go to Google Cloud Console
📁 Create a new project (important: create a new project specifically for this)
🔧 Enable Google Tag Manager API:
Inside your project, go to "APIs & Services" > "Library"
Search for "Tag Manager API"
Click on it and press "Enable"
3. Create OAuth 2.0 Credentials
🔑 On the Tag Manager API page, click "Create Credentials" button
❓ In "What data will you be accessing?" select "User data"
📱 In "OAuth Client ID" section:
Application type: select "Desktop app"
Give it any name you want
📥 Download the JSON file and save it as
credentials.jsonin the project root
4. Configure Test Users
👤 Go to "APIs & Services" > "Credentials" (left sidebar)
🔍 Find your newly created "OAuth 2.0 Client ID" and click on it
👥 Go to "Audience" tab, scroll down to "Test Users" section
➕ Add your email address as a test user
5. Run Authorization
# Build the project first
npm run build
# Run authorization
npm run authThis will:
Open a browser window for Google authorization
Redirect you to sign in with the email you added as a test user
After successful authorization, show a success page at
http://localhost:3000/callbackCreate a
gtm-config.jsonfile with access tokens in your project
6. Configure Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"google-tag-manager": {
"command": "node",
"args": ["/FULL/PATH/TO/YOUR/gtm-mcp-server/dist/index.js"],
"env": {
"PATH": "/usr/local/bin:/usr/bin:/bin"
}
}
}
}⚠️ Important: Replace /FULL/PATH/TO/YOUR/gtm-mcp-server/ with the actual absolute path to your project folder.
For example:
macOS:
"/Users/wiefix/WORK/gtm-mcp-server/dist/index.js"Windows:
"C:\\Users\\YourName\\Documents\\gtm-mcp-server\\dist\\index.js"
PATH explanation: The PATH environment variable specifies directories where system executables (like node) are located. On macOS/Linux, these standard paths ensure the MCP server can find Node.js.
7. Restart Claude Desktop
After saving the configuration file, restart Claude Desktop to connect the MCP server.
🛠️ Available Tools
📊 gtm_account
GTM account management
get- get account detailslist- list all accountsupdate- update account settings
📦 gtm_container
GTM container management
get- get container detailslist- list containers in accountcreate- create new containerupdate- update containerdelete- delete container
🚀 gtm_workspace
GTM workspace management
get- get workspace detailslist- list workspaces in containercreate- create new workspaceupdate- update workspacedelete- delete workspace
📁 gtm_folder
Folder management for organizing elements
get- get folder detailslist- list folders in workspacecreate- create new folderupdate- update folderdelete- delete folder
🏷️ gtm_tag
GTM tag management
get- get tag detailslist- list tags in workspacecreate- create new tagupdate- update tagdelete- delete tag
⚡ gtm_trigger
GTM trigger management
get- get trigger detailslist- list triggers in workspacecreate- create new triggerupdate- update triggerdelete- delete trigger
🔢 gtm_variable
GTM variable management
get- get variable detailslist- list variables in workspacecreate- create new variableupdate- update variabledelete- delete variable
🔧 gtm_builtin_variable
GTM built-in variable management
list- list built-in variablescreate- enable built-in variable (pageUrl, pageTitle, etc.)delete- disable built-in variable
💬 Usage Examples
After setup, you can ask Claude:
Basic navigation:
"Show all my GTM accounts"
"List containers in account 123456"
"Show workspaces in container 456789"
Organization:
"Create folder 'Analytics Tags' for organizing tags"
"List all folders in workspace"
Working with tags:
"Create Google Analytics tag with Measurement ID GA_MEASUREMENT_ID"
"Show all tags in workspace 7"
"Update tag with ID 15 with new settings"
"Delete unused tag"
Triggers:
"Create trigger for all page views"
"Create click trigger for button with class 'download-btn'"
"List all triggers"
Variables:
"Enable built-in variable Page URL"
"Create custom variable for GA Measurement ID"
"Show all variables in workspace"
🔧 Troubleshooting
Authorization Errors
Make sure
credentials.jsonis in the project rootVerify that Google Tag Manager API is enabled in your Google Cloud project
Check that your email is added as a test user in OAuth consent screen
Try running
npm run authagain
API Errors
Ensure your Google account has access to GTM accounts
Check access permissions in GTM interface
Verify that the API is enabled and credentials are correct
Connection Errors
Restart Claude Desktop after making configuration changes
Verify correct absolute paths in
claude_desktop_config.jsonCheck that the
dist/index.jsfile exists (runnpm run buildif missing)
📁 File Structure
gtm-mcp-server/
├── credentials.json # Your Google OAuth credentials (downloaded from Google Cloud)
├── gtm-config.json # Access tokens (auto-created after successful authorization)
├── src/ # TypeScript source code
├── dist/ # Compiled JavaScript (created by npm run build)
├── package.json # Project dependencies and scripts
└── README.md # This instruction file⚠️ Security
Files
credentials.jsonandgtm-config.jsoncontain sensitive authentication dataThese files are automatically added to
.gitignoreto prevent accidental commitsNever publish these files in public repositories or share them
Keep your Google Cloud project credentials secure
🔄 Development
# Development mode with auto-reload
npm run dev
# Build project for production
npm run build
# Code linting and formatting
npm run lint
# Re-run authorization if needed
npm run auth📞 Support
If you encounter problems:
Double-check all setup steps - make sure you followed the exact sequence
Verify Node.js version - ensure you're using Node.js v20.19.5 or higher
Check Google Cloud setup:
Project created and Tag Manager API enabled
OAuth credentials created as Desktop app
Your email added as test user
Verify file paths in Claude Desktop config are absolute and correct
Check logs in Claude Desktop terminal for error messages
Rebuild the project with
npm run buildif needed
🎯 Quick Verification
To verify everything works:
Complete all setup steps above
Restart Claude Desktop
Open a new chat in Claude
Ask: "List my GTM accounts"
You should see your Google Tag Manager accounts listed
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/metkamedia/gtm-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server