Why connect GTM to Codex?
Codex runs in your terminal, its IDE extension and scripts, so what it finds once can be rerun with codex exec instead of redone by hand. Connected through Lemonado, it reads your GTM tags, triggers, variables and versions, so it can check tags against consent with today's numbers.
All your GTM data
Accounts, containers and workspaces, ready to ask about.
Always today's numbers
Triggers and the conditions behind them, synced from GTM automatically, so answers use today's numbers.
Connect all your tools
Questions like "Why did conversions drop?" use GTM and GA4, Google Ads at once.
How to connect GTM to Codex
Before you start
- A Google Tag Manager account you can sign in to
- Codex installed
- A Lemonado account (the free trial works)
- 1
Connect Google Tag Manager in Lemonado
In Lemonado, open Connectors, find Google Tag Manager and sign in. Sign in with a Google account that has at least Read access to the GTM containers you want to audit. Pick the web container your site uses.
- 2
Turn on external access
In the company's settings, open External tools, turn the connection on, choose which sources it can reach and copy the server URL.
texthttps://mcp.lemonado.io/mcp - 3
Add Lemonado to your config
Add this to ~/.codex/config.toml.
toml[mcp_servers.lemonado] url = "https://mcp.lemonado.io/mcp" - 4
Log in
Run the login command and finish the sign-in in your browser.
bashcodex mcp login lemonado - 5
Ask Codex about GTM
Run codex mcp list, or /mcp inside Codex, to see the server and its tools. Try "Pull last week's GTM numbers, save them to data/google-tag-manager-weekly.csv and give me the codex exec command to refresh it." Or ask: "What breaks if I rename this?" or "Does the dataLayer match GTM?"
What can Codex do with GTM?
Codex reads your GTM data from your terminal and turns one-off questions into commands you can rerun with codex exec.
Pull last week's GTM numbers, save them to data/google-tag-manager-weekly.csv and give me the codex exec command to refresh it.
Saved data/google-tag-manager-weekly.csv. Run the same prompt with codex exec in a scheduled job and the file refreshes with each week's numbers.
Source: Google Tag Manager + your code
If we rename ecommerce.value to ecommerce.revenue, which GTM variables, triggers and tags would stop working?
One variable reads it, and 9 purchase tags use that variable across Google Ads, Meta, TikTok and GA4.
Source: Google Tag Manager + your code
Compare every dataLayer.push key in our repo with the data layer variables and custom event triggers in our GTM container.
3 GTM triggers listen for events the code no longer pushes, including checkout_step.
Source: Google Tag Manager + your code
Write docs/tracking.md listing each dataLayer event, the GTM tags it fires and the platforms that receive it.
Saved. 18 events, 46 tags and a table of which platform gets each conversion.
Source: Google Tag Manager + your code
Compare the live GTM version with the one before it. What tags, triggers or variables changed?
Version 212 edited the purchase trigger to fire on /thank-you only. Checkout now ends on /order-complete, so the purchase tags stopped firing.
Source: Google Tag Manager
List tags in our GTM container that have no consent settings, grouped by vendor.
14 tags have no consent check: 8 custom HTML pixels, 4 Meta tags and 2 LinkedIn Insight tags. All GA4 and Google Ads tags use consent mode.
Source: Google Tag Manager
Connect GTM to another AI app.
Claude
Connect GTM to Claude
ChatGPT
Connect GTM to ChatGPT
Claude Code
Connect GTM to Claude Code
Cursor
Connect GTM to Cursor
VS Code (GitHub Copilot)
Connect GTM to VS Code (GitHub Copilot)
Perplexity
Connect GTM to Perplexity
Google Antigravity
Connect GTM to Google Antigravity
Windsurf (Devin Desktop)
Connect GTM to Windsurf (Devin Desktop)
Zed
Connect GTM to Zed
n8n
Connect GTM to n8n
Other integrations for Codex
All Codex integrations- Google Analytics in CodexAsk Claude, ChatGPT or Cursor about GA4 traffic, conversions and funnels, next to your ad spend.
- Google Ads in CodexAsk Claude, ChatGPT or Cursor about your Google Ads campaigns, search terms and spend.
- Meta Ads in CodexAsk Claude, ChatGPT or Cursor about your Facebook and Instagram ads, creatives and results.
- Instagram organic in CodexAsk Claude or ChatGPT which posts and reels grow your account, and which ones to turn into ads.
- Pinterest Ads in CodexAsk Claude or ChatGPT which pins get saved, clicked and bought.
- Snapchat Ads in CodexAsk Claude or ChatGPT which Snapchat ads get swipes and which ones sell.
Reading this as an AI agent?
Everything an agent needs to set this up, in plain text. Paste this page's link into Codex and ask it to connect you, or copy the block.
# Connect Google Tag Manager to Codex (Lemonado MCP) - Server URL: https://mcp.lemonado.io/mcp - Transport: Streamable HTTP - Auth: OAuth; the user signs in to Lemonado in the browser. No API keys. - In Lemonado: connect the GTM account and container. Sign in with a Google account that has at least Read access to the GTM containers you want to audit. Pick the web container your site uses. - In Codex: ~/.codex/config.toml ```toml [mcp_servers.lemonado] url = "https://mcp.lemonado.io/mcp" ``` If you are Codex, run the setup yourself: Add the Lemonado MCP server to my Codex config. Append this to ~/.codex/config.toml: [mcp_servers.lemonado] url = "https://mcp.lemonado.io/mcp" Then run codex mcp login lemonado so I can sign in, and check that codex mcp list shows it. Once I've signed in, list the Google Tag Manager accounts Lemonado can reach. First question to try: "Pull last week's GTM numbers, save them to data/google-tag-manager-weekly.csv and give me the codex exec command to refresh it." More: https://lemonado.io/integrations/google-tag-manager · https://lemonado.io/llms.txt
Frequently Asked Questions
Yes, through Lemonado. Connect your GTM account and container in Lemonado, add Lemonado in ~/.codex/config.toml, and Codex can check tags against consent with your live data.
No, Google doesn't run one. Community servers exist, and most can edit and publish your container, so check what you grant them. Lemonado gives Codex read-only access to your containers, next to GA4 and your ad platforms.
Run codex mcp list. If lemonado shows as not logged in, run codex mcp login lemonado again. In Lemonado, check that Google Tag Manager is connected and External tools is on for the company. If a container is missing, your Google user needs access to it in Tag Manager > Admin > User Management. Account access alone isn't always enough.
Yes, if both are connected in Lemonado. One connection reaches every source you allow, so you can ask things like "Google Ads conversions fell on Oct 18. Check which GTM version was published that week and what it changed."
MCP is included in Lemonado's paid plans and in the free trial, so you can try it before you pay.
Still have a question?
Shoot us an email at hello@lemonado.io.
Try for freeStop fighting with data. Start feeding your AI.
Connect your data to AI and free your team from reporting and busywork.
Try Lemonado free