Tracking bugs often sit between website code and Tag Manager configuration. Connecting Codex to GTM lets one investigation inspect both the repository's dataLayer calls and the container's triggers. This guide uses a source-specific MCP server so your session can retrieve the actual configuration while you inspect the relevant code.
What do you need before connecting?
Use an installed Codex CLI with remote HTTP MCP and OAuth support. Run the setup on the same Codex host where you will use the tools. A local CLI configuration does not by itself configure a separate cloud task. You need no Google service-account JSON or API key for this hosted OAuth route.
- A Google login that can read the intended Tag Manager container.
- A LoomaScale account with Google Tag Manager connected separately from Analytics or Google Ads.
- The container you want to inspect, plus a named workspace if you later request a draft change. Editing, creating versions and publishing require their corresponding Google permissions.
How do you connect Codex to GTM?
1. Connect GTM in LoomaScale
Create or sign in to your LoomaScale account, then open Connections. Choose Google Tag Manager, sign in with the Google email that has access to the required data, and review the requested permissions. Signing in to LoomaScale with Google is not a substitute for connecting this data source. You can connect this service without connecting an advertising account.
2. Add the source-specific MCP server to Codex
Run these commands in your terminal. The first saves the remote server and the second starts browser authorization. The server name is specific to this Google source, so another source can be added without replacing it.
codex mcp add loomascale-gtm --url https://api.loomascale.com/mcp/gtm
codex mcp login loomascale-gtm3. Finish OAuth and check the active Codex connection
Complete LoomaScale authorization in the browser using the account with your Google connection, then return to the terminal. Run codex mcp list to check the saved server. Start or reopen a Codex session and use /mcp to inspect its active tools. A saved entry is configuration evidence; the account lookup below verifies data access. Codex's supported local clients share MCP configuration for the same host. Consult OpenAI's current documentation for your desktop or IDE surface; do not assume a different host inherited your login.
4. Verify access with an actual account lookup
Use LoomaScale to call gtm_list_containers. Show each container's name, public GTM ID and account. Ask me which one to inspect. Read its published version and list its workspaces. Do not edit, create a version or publish anything.
Check that the response identifies your actual container, including its GTM- public ID. Distinguish the published version from each draft workspace before discussing a tracking issue. The container's API account and container IDs are different identifiers from its public GTM- ID; let the tools discover the required values. A successful inventory confirms access to configuration, not that a browser event fires correctly.
How do you compare dataLayer events with GTM triggers in Codex?
Start with a known user action, such as a completed lead form. Identify its dataLayer event name and payload in code, then retrieve the published GTM triggers and the tags they fire. Match exact spelling and required fields. Inspect a named draft workspace separately if it contains a proposed correction.
Use LoomaScale and the GTM container I selected. Read this repository's dataLayer event for successful lead submissions without editing files. Retrieve the published tags, triggers and variables for that event. Compare exact event names, conditions and required payload fields. List mismatches supported by code or container data, and browser tests needed to confirm behavior. Do not modify files, edit GTM or publish.
A matching event name does not establish that the payload arrives at the right moment or with the expected consent state. Codex should identify what static code and container inspection can establish, then provide a specific browser test. If the proposed fix changes a shared variable, review every dependent tag before deciding where to implement it.
Which MCP endpoint does this guide use?
https://api.loomascale.com/mcp/gtmThe service-specific endpoint exposes GTM tools and LoomaScale account helpers. The full directory plugin or connector uses https://api.loomascale.com/mcp and can reach all sources you separately connect. Choose the full connection for work across services; use the specific endpoint when you want this source's tool set. An endpoint choice limits exposed tools, not the Google roles your login holds.
What can Codex read or change in GTM?
LoomaScale reads containers, tags, triggers, variables, workspaces, versions and tracking-audit findings. Where enabled and authorized, changes go into the workspace you select; creating a version and publishing it are separate operations. Review the exact version before approving publication. Configuration inspection cannot observe a visitor's browser or prove that consent and tags behave correctly on the site. Validate proposed changes in Tag Manager Preview and Tag Assistant before a live release.
Why is the connection or data missing?
If authorization is missing, run codex mcp login loomascale-gtm again. If the entry is configured but absent in the active session, restart that session and inspect /mcp. Check the URL and host if the tools still do not load. The main LoomaScale plugin and the service-specific server are alternative connections; installing both can expose duplicate tool sets.
A missing container usually calls for checking the Google login, container access and Tag Manager connection. If discovery says accounts are still loading, retry after discovery finishes. If an audit describes different tags from the live site, check whether you requested the published version or a draft workspace. A write-permission error is separate from read access: check the relevant edit, version or publish permission and the feature's availability before reconnecting.
Related connection guides and official references
Use GTM in another assistant
- How to Connect ChatGPT to GTM
- How to Connect Claude to GTM
- How to Connect Claude Code to GTM
- How to Connect Grok Build to GTM
Connect another Google source to Codex
Official setup references
Setup references checked on November 12, 2026. Menu labels and workspace policies can change; use the linked vendor guidance for your account. For LoomaScale's supported workflows, see the documentation hub.
