- Home
- MCP servers
- Google Tag Manager
Google Tag Manager
- python
1
GitHub Stars
python
Language
5 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"neep305-mcp-for-gtm": {
"command": "python",
"args": [
"/path/to/mcp-for-gtm/server.py"
],
"env": {
"GTM_TOKEN_FILE": "/path/to/mcp-for-gtm/token.json",
"GTM_CREDENTIALS_FILE": "/path/to/mcp-for-gtm/credentials.json"
}
}
}
}You can run a Python-based MCP server that automates Google Tag Manager setup through natural prompts. It integrates GTM API access with component templates and workflow automation, enabling quick creation and management of GTM configurations through an MCP client.
How to use
You interact with the GTM MCP server through an MCP client. Start the server using the configured stdio entry and then issue prompts to create GTM tags, triggers, variables, or complete workflows for your site type. Use the provided tool names to perform specific actions, or ask for end-to-end setups like a GA4 configuration, an ecommerce tracking workflow, or form tracking.
How to install
Prerequisites: Python must be installed on your system. A Python environment is required to run the MCP server.
Install dependencies using pip.
pip install -r requirements.txt
Configuration and runtime
This server uses a Google Cloud service account to access the Tag Manager API. You will provide credentials in JSON format and a token file to persist authentication.
The MCP client config should reference the GTM server with a Python command that runs the server script and passes the path to credentials.
{
"mcpServers": {
"gtm": {
"command": "python",
"args": ["/path/to/mcp-for-gtm/server.py"],
"env": {
"GTM_CREDENTIALS_FILE": "/path/to/mcp-for-gtm/credentials.json",
"GTM_TOKEN_FILE": "/path/to/mcp-for-gtm/token.json"
}
}
}
}
Usage patterns and capabilities
The server exposes a set of tools to manage GTM programmatically. You can create and configure GTM tags, triggers, and variables, list containers, fetch container details, and publish container versions. You can also generate complete GTM workflows for different site types and set up common configurations like GA4 and Facebook Pixel.
Security and authentication
On first run, the server will guide you through OAuth authentication. Follow the prompts to grant access to your GTM account. The authentication token is saved for subsequent runs.
Troubleshooting
If you encounter authentication issues, ensure that your credentials.json is valid and that the Tag Manager API is enabled for your Google Cloud project. Verify that your GTM account has the required edit permissions for the container.
If you see permission errors, double-check the GTM container IDs and workspace access. Check API rate limits if you are issuing many requests in a short period.
Development and testing
Run tests or start the server to verify end-to-end GTM interactions in a development environment.
# Example: run tests
python test_server.py
# Start server directly if needed
python server.py
Available tools
create_gtm_tag
Create a Google Tag Manager tag with specified configuration and firing rules.
create_gtm_trigger
Create a GTM trigger to define when a tag should fire.
create_gtm_variable
Create a GTM variable to hold data from your site or GTM data layer.
list_gtm_containers
List all GTM containers in the linked GTM account.
get_gtm_container
Retrieve details for a specific GTM container.
publish_gtm_version
Publish a new container version to apply changes live.
create_ga4_setup
Set up Google Analytics 4 tracking in GTM with a GA4 config tag and common events.
create_facebook_pixel_setup
Configure Facebook Pixel tracking within GTM.
create_form_tracking
Set up form submission tracking for a given form selector.
generate_gtm_workflow
Generate complete GTM workflows for ecommerce, lead generation, or content sites.