This project focuses on building programs and prompts to automate Google Tag Manager (GTM) implementation tasks using AI.
- Extraction: Using the Google Tag Manager API, the tool retrieves existing components such as tags, triggers, and variables, and saves them in JSON format.
- AI-Powered Modification: AI is used to update the JSON files, performing the actual tag implementation logic within the files.
- Synchronization: Once the implementation (JSON editing) is complete, the changes are synced back to Google Tag Manager using the API.
To ensure portability and ease of setup, this project is implemented using only the Python standard library. No external dependencies (such as requests or google-auth) are required.
- Programming Language: Python 3.x (Standard Library only)
To use GTM Copilot as an AI Agent skill, follow these steps:
-
Download: Clone this repository into your agent's skill directory.
For Claude Code:
# User-level git clone https://github.com/sem-technology/gtm-copilot.git ~/.claude/skills/gtm-copilot # Project-level git clone https://github.com/sem-technology/gtm-copilot.git .claude/skills/gtm-copilot
For Gemini (including Antigravity):
# User-level git clone https://github.com/sem-technology/gtm-copilot.git ~/.agent/skills/gtm-copilot # Project-level git clone https://github.com/sem-technology/gtm-copilot.git .agent/skills/gtm-copilot
-
Authentication:
- Copy
.env.exampleto.envin the skill directory. - Run the authentication script to generate your refresh token:
python scripts/bin/auth.py
- Follow the prompts to authorize and update the values in your
.envfile.
- Copy
-
Usage: Once placed and authenticated, your AI Agent will automatically recognize the tools defined in
SKILL.mdand can start automating your GTM workflow.
You can customize the behavior of GTM Copilot using environment variables. These should be defined in a .env file located in the project root directory (or the skill directory):
GTM_CLIENT_ID: The OAuth 2.0 Client ID obtained from the Google Cloud Console.GTM_CLIENT_SECRET: The OAuth 2.0 Client Secret obtained from the Google Cloud Console.GTM_REFRESH_TOKEN: The OAuth 2.0 Refresh Token generated by runningauth.py. Used for automatic access token renewal.GTM_EXPORT_ROOT_PATH: Defines the root directory for exporting and importing GTM configurations.- Placeholder: Supports
[[GTM_ID]], which is automatically replaced by the container's public ID (e.g.,GTM-XXXXXX). - Default:
tmp/[[GTM_ID]] - Priority: Command-line arguments > Environment variable > Default path.
- Placeholder: Supports
To update the skill to the latest version, navigate to the skill directory and run:
# User-level (example)
cd ~/.agent/skills/gtm-copilot
git pull origin mainFor more information on Agent Skills, please refer to agentskills.io.