How to connect Claude to Google Tag Manager
To The Sky ·
We connect Claude to Google Tag Manager through a GTM MCP server and use Chrome DevTools MCP to test tracking on the site. At To The Sky, Claude builds tags and triggers in a draft workspace, checks what fires, and leaves the review and publishing to us.
7 pages8 promptsWhat's inside the guide
- ✓What you need and how long it takes (once, about 30 minutes)
- ✓The 3 setup steps: Google Cloud, the GTM connector, Chrome DevTools
- ✓The build and test workflow, before you publish
- ✓8 prompts to copy, for auditing and building
- ✓Common traps and how to avoid them
How Claude sets up a conversion
- 1Claude creates the tag and trigger in a draft workspace
- 2It opens the site in Chrome and does the action
- 3It checks the request, the dataLayer and the console
- 4It tells you what fired and what didn't
- 5You review and publish
| Item | Why | Notes |
|---|---|---|
| Claude Code | This is where we connect and use the MCP servers. | Use the terminal or the Code tab in the Claude desktop app. |
| Google account with GTM container access | We use it to authorize access to the container. | The OAuth setup produces the JSON file needed by the connector. |
| Node.js | Chrome DevTools MCP needs it. | It must be installed. |
| GTM MCP server | It lets Claude read and edit the container. | We use VasthavM/google-tag-manager-mcp. The guide also includes the Stape alternative. |
| Chrome DevTools MCP | It lets Claude test the site in Chrome. | Free, from the Google Chrome team. |
| About 30 minutes | For the initial setup. | This is a one-time setup. |
Claude Code
- Why
- This is where we connect and use the MCP servers.
- Notes
- Use the terminal or the Code tab in the Claude desktop app.
Google account with GTM container access
- Why
- We use it to authorize access to the container.
- Notes
- The OAuth setup produces the JSON file needed by the connector.
Node.js
- Why
- Chrome DevTools MCP needs it.
- Notes
- It must be installed.
GTM MCP server
- Why
- It lets Claude read and edit the container.
- Notes
- We use VasthavM/google-tag-manager-mcp. The guide also includes the Stape alternative.
Chrome DevTools MCP
- Why
- It lets Claude test the site in Chrome.
- Notes
- Free, from the Google Chrome team.
About 30 minutes
- Why
- For the initial setup.
- Notes
- This is a one-time setup.
What you need
What you get when Claude is connected
At To The Sky, we use this setup to turn a tracking request into a tag that has been built and tested. We tell Claude what we want to track. It can read every tag, trigger and variable in our GTM container, then create conversion tags and triggers in a draft workspace.
Two connectors do the work. The GTM connector uses MCP to give Claude access to tags, triggers, variables and versions. Chrome DevTools MCP lets Claude open the site and inspect network requests, the dataLayer and console errors.
We use the GTM connector to build the tag and Chrome DevTools to check that it fires on the site. Claude can check the configuration, perform the action in Chrome and report what works and what does not. We verify both the tag's presence in the container and its firing on the site.
The complete setup and workflow are below. The PDF stays available as an optional download. You can follow the instructions directly on this page. For the full picture, read our guide to Claude for marketing.
What we have ready before starting
We use Claude Code either in the terminal or in the Code tab of the Claude desktop app. We also need a Google account with access to the GTM container and Node.js installed for Chrome DevTools MCP. We allow about 30 minutes for the one-time setup.
We also choose which GTM connector we will use. Step 2 includes the two options from our guide. The Google Cloud setup in Step 1 gives us the JSON file that we will point the chosen connector to.
Before asking for a conversion tag, we decide which action we want to track. That might be a form submission or a purchase. We tell Claude which action is worth money in the business, and it configures the tracking in GTM.
Step 1: give Claude access to the Tag Manager API
We start in Google Cloud. This is the part with Google settings, and we do it once. The aim is to let the connector use the Tag Manager API through our Google account.
1. Go to console.cloud.google.com and create a project. Any name is fine.
2. In APIs & Services > Library, search for Tag Manager API and click Enable.
3. In OAuth consent screen, set up the app for your own account. The External type is fine.
4. In Credentials > Create credentials > OAuth client ID, choose Desktop app and download the JSON file.
5. Publish the consent screen to Production.
6. When the connector asks for access, approve the scopes for editing containers, editing container versions and publishing.
Keep the consent screen in Production. In Testing, Google expires access after 7 days and the connector stops working. Check this setting before completing the setup.
During sign-in, Google may say the app is not verified. It is our own app. We click Advanced > Go to [your project] and continue.
We leave out the "delete containers" scope, which Claude does not need. The publish scope gives it the ability to publish; in our workflow, we review and publish the changes.
Step 2: install the GTM connector
We use an open-source GTM MCP server. The one we run is VasthavM/google-tag-manager-mcp. It has about 50 tools, full read and write access, including publishing, and works with our personal Google sign-in.
The other option is stape-io/google-tag-manager-mcp-server. It is more mature, installs from npm and also supports a service account. It is a good choice if you are starting fresh.
1. Pick one of these servers and follow its README.
2. Point the connector to the JSON file downloaded in Step 1.
3. Sign in once with Google.
4. Add the connector to Claude with this command. [path to the connector] represents the path to your chosen connector.
claude mcp add gtm --scope user -- [path to the connector]
5. Restart Claude and ask it to list your GTM accounts and containers.
"List my GTM accounts and containers."
We use that request as the connection test. If the new connector does not appear, we check whether we restarted Claude. Claude only loads new connectors after a restart. The selected server's README handles its installation instructions; the command above adds it to Claude.
Step 3: add Chrome DevTools MCP
Next we add Chrome DevTools MCP, the free connector from the Google Chrome team. This gives Claude the browser access we use to inspect what happens on the site. It can see network requests, the dataLayer and console errors.
1. With Node.js installed, run the command below. It works in every project.
claude mcp add chrome-devtools -s user -- npx -y chrome-devtools-mcp@latest
2. Restart Claude.
3. Ask Claude to open your site and show any console errors.
"Open my site and show me any console errors."
The first run opens its own Chrome window. We use the request above to test this connection. For a specific conversion, we then use the full test workflow: Claude performs the action and checks the conversion request, the dataLayer event and the console.
How we build and test a conversion
Once both connections are working, we use the same workflow for each change. We ask Claude to create a new draft workspace and name it after the change, for example "purchase-tag-fix". That lets us see what it touched and gives us a workspace we can throw away.
1. We tell Claude which conversion we want. It creates the tag and trigger in a draft workspace.
2. Claude opens the site in Chrome and performs the action being tracked.
3. Claude checks the network request, the dataLayer and the console.
4. Claude reports what fired and what did not.
5. We review the result and publish.
In Network, we want to see the conversion request leave the page for Google Ads, GA4 or Meta, depending on the tag. In the dataLayer, we want the event to be present with the correct value and currency. In the console, we want zero errors from the tags.
Those checks are the basis of the report we ask for before publishing. We ask Claude to test the action on the site and tell us what works and what needs changing.
At To The Sky, Claude drafts and tests the change. We review the result and publish.
The questions and prompts we use
We start with an audit, then build. We use the questions below to inspect what is already in the container: tags that can fire twice, triggers that cannot fire, pixels that look forgotten and purchase values. We ask them separately depending on what we need to check.
1. Check for tags that can fire twice.
"Go through my GTM container and list every tag that can fire twice on the same page. Tell me why."
2. Find tags without a trigger that can fire.
"Which tags have no trigger, or a trigger that can never fire?"
3. Review old pixels.
"List all third-party pixels in the container and when each was last changed. Flag the ones that look forgotten."
4. Check purchase values.
"Check my purchase tags. Do they send the order value and currency from the dataLayer, or a fixed number?"
5. Compare versions.
"Compare the live version with the previous one. What changed?"
After the audit, we specify the tag we want built and explicitly say not to publish. We replace the bracketed choices with the platform and action we want to use.
6. Build in a new draft workspace.
"In a new draft workspace, create a [Google Ads / GA4 / Meta] conversion tag for [form submit / purchase] and the trigger for it. Don't publish."
7. Run the browser test.
"Open [URL] in Chrome, do the [form submit / purchase] step, and confirm the conversion request is sent, the dataLayer event is correct and there are no console errors."
8. Get the report before publishing.
"Give me a short list: what works, what doesn't, and what you'd change before I publish."
Common traps and how to avoid them
Keep the consent screen in Production. In Testing, access expires after 7 days. Check this setting before completing the Google setup.
After adding a connector, restart Claude before testing it. Claude only loads new connectors after a restart.
For every change, ask for a new draft workspace named after the change. If you want to discard that work, you can throw the workspace away.
Confirm that the tag works with a Chrome test. Check the request being sent, the dataLayer event and the console errors.
Tell Claude which action matters to the business. Choose the conversion based on its value to the business, then ask Claude to configure the tracking in GTM.
What we decide and review
We decide which business action deserves to be tracked as a conversion and give Claude that direction. We verify that the tag fires with the Chrome test, checking the request, the dataLayer and the console.
In our workflow, Claude prepares changes in a draft workspace, tests them and gives us the report. We review and publish.
If you want us to check your tracking, we run this audit for agencies and businesses that spend on Meta and Google Ads. Send us a LinkedIn message with "GTM audit" and your site, and we will tell you the first three things we would fix.
This is post 1 of 7 in our series on connecting Claude to the tools we use to run ads. Next is Google Analytics 4 and how we check whether the numbers in it are real.
How we made this guide: we started from our own work, in the accounts we manage and the tools we use. An AI assistant helped us with the draft and structure. Before publishing, we checked every figure, step and link against our own data and setup.
In short
We use GTM MCP to build tracking and Chrome DevTools MCP to check what fires on the site. We tell Claude which conversion we want, ask for a new draft workspace and review its report before we publish. Every step is on this page, with the PDF available as an optional download.
Get the free guide
