marketerswiki
Home
Resources
Learn
marketerswiki

The open playbook for performance marketers who build with AI.

Resources

  • SimpleCRM
  • Ads OS
  • Ledgeros
  • Tag Manager Engine
  • Skills
  • Playbooks
  • Vibecoding

Learn

  • Blog
  • Glossary
  • How-To Guides
  • Compare Tools
  • Claude Code For...
  • AI Tools Directory

Company

  • About
  • Privacy Policy
  • Terms of Service

© 2026 marketers wiki. All rights reserved.

Built withClaude Code
  1. Home
  2. /
  3. How-To
  4. /
  5. Set Up GTM with Claude Code
How-To Guide

How to Set Up Google Tag Manager with Claude Code

6 steps2-4 hours to complete10 min read

By the end of this guide, you will have a fully implemented GTM container with your key tracking tags, triggers, and variables - audited for errors, tested in GTM Preview mode, and documented in a stakeholder report. The whole process takes 2 to 4 hours, compared to 3 to 5 days with the traditional developer workflow.

Before you start

You will need the following before running this guide:

  • Claude Code installed: Not installed yet? Follow the installation guide. Takes under 10 minutes.
  • GTM account access: You need at least Editor access to the GTM container you want to work with. Admin access is required for publishing.
  • GTM container export (for auditing): In GTM, go to Admin > Container Settings > Export Container. Save the JSON file to your working directory.
  • A tracking requirements document: A list of what you need to track: page views, form submissions, purchases, button clicks, etc. This can be a simple bullet list or a formal spec.
  • GTM API access (for implementation): Only needed if you want Claude Code to push tags directly to GTM. For auditing and planning, the JSON export is enough. The Tag Manager Engine handles API setup for you.

Step 1: Install the GTM Automation skill in Claude Code

The GTM Automation skill is a set of instructions that tells Claude Code how to work with Google Tag Manager. It gives Claude Code knowledge of GTM best practices, tag types, trigger logic patterns, and the output format for audit reports, implementation plans, and stakeholder reports.

To add the skill to your Claude Code session, run the following command in your terminal from your project directory:

claude --skill gtm-automation

Alternatively, you can use the Tag Manager Engine - a web interface on marketers.wiki that has the GTM skill pre-loaded and guides you through each step of this workflow automatically.

Once the skill is loaded, Claude Code will confirm it is ready and ask for your first instruction. You are ready to move to the audit.

Step 2: Run the GTM audit

The audit is the foundation of the whole workflow. It maps your existing container - every tag, trigger, variable, and the relationships between them - and surfaces every issue before you touch anything.

Make sure your GTM container export JSON is in your working directory. Then run this prompt in Claude Code:

You are a Google Tag Manager specialist. I have my GTM container exported at ./gtm-container-export.json. Run a full audit of this container and produce a structured report covering: 1. TAGS - List every tag, its type, its trigger assignment, and flag any issues (no trigger assigned, firing on wrong pages, duplicate conversion tags, hardcoded values that should be dynamic variables). 2. TRIGGERS - List every trigger. Flag triggers that are unused, triggers with overlapping conditions, and triggers using page URL rules that are fragile (e.g. "contains /thank-you" which breaks if the URL changes). 3. VARIABLES - List every variable. Flag dataLayer variables that are referenced in tags but not defined, and variables that are defined but not used anywhere. 4. NAMING CONVENTIONS - Identify any inconsistencies in dataLayer variable names (camelCase vs snake_case vs PascalCase). List every variable with its current name and the recommended standardised name. 5. PRIORITY ISSUES - Top 5 most critical issues with impact explanation for each. Format as a structured markdown report. Include a summary table at the top showing total counts and total issues found.

Claude Code reads the container JSON and produces the report in under 2 minutes for most containers. A typical output includes a summary table, the priority issues list, and a complete inventory of every container element with status flags.

What the audit output looks like:

Example output (excerpt)

## GTM Container Audit Container: GTM-XXXXX Audited: 52 tags | 38 triggers | 29 variables ### Summary | Category | Total | Issues found | |----------|-------|--------------| | Tags | 52 | 11 | | Triggers | 38 | 6 | | Variables| 29 | 5 | ### Priority Issues 1. CRITICAL - GA4 Purchase tag fires on all pages (trigger error) 2. CRITICAL - 3 dataLayer variables referenced but not defined 3. HIGH - Naming inconsistency: userId / user_id / UserId across 8 tags 4. HIGH - 6 orphaned tags with no trigger assigned 5. MEDIUM - Google Ads remarketing uses hardcoded conversion label [Full inventory continues...]

Save this report. You will reference it in the next steps and include it in the final stakeholder report.

Step 3: Review and approve the strategy

This is the approval gate - the most important step in the workflow. Claude Code will not make any changes to your GTM container until you have explicitly approved its implementation plan.

After reviewing the audit report, provide Claude Code with your tracking requirements and ask it to produce an implementation plan:

Based on the audit findings and the following tracking requirements, produce a full implementation plan. Do not make any changes yet. Tracking requirements: - GA4 configuration tag on all pages - GA4 purchase event with transaction_id, value, currency, items - GA4 add_to_cart event with product_id, product_name, value - GA4 form_submit event on all contact forms - Google Ads conversion tag on /thank-you pages (conversion label: XXXXX) - Meta Pixel base code on all pages - Meta Pixel Purchase event on /order-confirmation with value and currency For each item, specify: - Tag name (following [Platform] - [Event] naming convention) - Tag type and configuration - Trigger to create or reuse - Variables needed (new or existing) - Any dependencies or order of implementation Present the plan as a table I can review before you proceed.

Claude Code will return a structured table showing every tag it plans to create or modify, the trigger logic, and the variables required. Review this carefully.

What to check in the implementation plan:

  • Every tag you need is included - compare against your requirements doc
  • Trigger logic matches the pages or events where each tag should fire
  • Variable names follow your preferred naming convention (agree on this before approving)
  • No tags are being deleted that you still need
  • The order of implementation makes sense (configuration tags before event tags)

When you are satisfied, respond with "Approved - proceed with implementation." If you want changes, describe them and Claude Code will update the plan before proceeding. You can cycle through this as many times as needed.

Important: Never skip this step. Reviewing the plan before implementation is what keeps Claude Code's output aligned with your actual requirements. It takes 5-10 minutes and saves you from having to undo incorrect implementations.

Step 4: Run implementation

With the plan approved, Claude Code creates every tag, trigger, and variable in the order specified in the implementation plan.

If you have GTM API access configured, Claude Code pushes the changes directly to a new workspace in your GTM container. If not, it generates an updated container JSON that you can import via GTM Container Settings -> Import Container.

For each item in the implementation plan, Claude Code will:

  • Create the variable definition (if a new dataLayer variable is needed)
  • Create the trigger with the correct trigger type and condition logic
  • Create the tag, assign the trigger, and map all parameters to the correct variables
  • Confirm the dependency chain is intact (tag references trigger, trigger fires, variables resolve)
  • Log the change with a human-readable description

Implementation of a 10-15 tag setup typically takes 5 to 15 minutes. Claude Code outputs a change log as it works, so you can see exactly what has been created.

When implementation is complete, Claude Code will confirm the total number of tags, triggers, and variables created, and flag any items it was not able to implement automatically (these are usually edge cases that need manual configuration).

Step 5: Test the implementation

Never publish a GTM container without testing in Preview mode first. Claude Code produces a testing checklist that tells you exactly what to do in GTM Preview mode to verify every tag is working correctly.

Ask Claude Code for the testing checklist:

Based on the implementation we just completed, produce a GTM Preview mode testing checklist. For each tag, specify: 1. Which URL to visit or which action to perform in the browser 2. Which tag name should appear in the GTM Preview panel as "Fired" 3. Which variables should be populated in the dataLayer (with example expected values) 4. What to check in the GA4 DebugView or browser network tab to confirm the event fired correctly Format as a numbered checklist I can work through in order.

Open GTM Preview mode (Submit -> Preview in GTM), visit your site, and work through the checklist. For each tag:

  • Confirm the tag appears under "Tags Fired" in the GTM Preview panel after performing the specified action
  • Check the Variables tab to confirm dataLayer variables are populated with real values, not undefined
  • For GA4 tags, open GA4 DebugView (configure.google.com/analytics) and confirm the event appears with the correct parameters
  • For Google Ads tags, check the network tab in browser DevTools and confirm the conversion ping fires
  • For Meta Pixel, use the Meta Pixel Helper browser extension to confirm events

Document your test results - pass or fail for each tag. If a tag fails, describe the issue to Claude Code and it will diagnose and fix it. Re-test after any fix before moving to the next tag.

Once every tag has passed testing, you can publish the GTM workspace. In GTM, click Submit, add a version name (e.g. "AI implementation - [date]") and a brief description, then Publish.

Step 6: Generate the tracking report

The final step is generating a tracking implementation report. This document captures everything that happened in the workflow - the audit findings, the implementation decisions, and the test results - in a format that non-technical stakeholders can read.

Ask Claude Code to write the report:

Based on everything we have done in this session - the audit, the implementation plan, the implementation itself, and the test results - write a tracking implementation report. The report should include: 1. Executive summary (3-4 sentences: what was done, what was found, what is now live) 2. Audit findings summary (table of issues found, with status: fixed / not in scope / to be addressed) 3. Implementation summary (table of all tags implemented, their status, and what they track) 4. Testing summary (table of all tags tested, pass/fail result, and any notes) 5. What is now live (plain-language description of what data is now being collected and where it goes) 6. Recommended next steps (any items flagged during audit that were not addressed in this implementation) Write it for a non-technical audience. Avoid jargon. Use plain language throughout. Format as a clean markdown document.

The report Claude Code produces covers everything from the initial audit findings to the final published state of the container. It is ready to share with clients, managers, or the wider team without any editing.

Save the report to your project folder alongside the original audit findings. This becomes your documentation for the implementation and a reference point for future changes to the container.

Common mistakes to avoid

These are the three most common ways marketers get tripped up when running this workflow for the first time.

1

Skipping the audit

It is tempting to jump straight to implementation when you know what tags you need. The audit exists to surface problems you do not know about - undefined variables, conflicting triggers, duplicate tags. Skipping the audit means you implement on top of a broken foundation. This always creates more work later.

2

Not reviewing the strategy before implementation

The implementation plan is Claude Code's interpretation of your requirements. It is very good, but it is not perfect. Review the plan carefully before approving. Pay particular attention to trigger logic - a tag that fires on the wrong trigger can inflate your conversion data by orders of magnitude. Five minutes of review saves hours of debugging.

3

Testing in production

Always use GTM Preview mode for testing. Preview mode lets you test your changes against the live site without publishing them - the tags fire in your browser session only. Publishing before testing means errors go live immediately and can corrupt your data for the entire period until they are fixed. Never skip the test step.

Frequently asked questions

How long does GTM setup take with Claude Code?

For a new container with a clear tracking requirements document, the full workflow - audit, plan, implement, test, report - typically takes 2 to 4 hours. This compares to 3 to 5 days for the same work done manually with developer involvement. The audit step alone takes under 5 minutes. The time varies based on the size of your container and the number of tags you are implementing.

Do I need the GTM API or just GTM access?

For auditing only, you can export your GTM container as JSON and give it to Claude Code - no API needed. For implementation (writing tags back to GTM), you need GTM API access via a Google Cloud project with the Tag Manager API enabled. The Tag Manager Engine handles this API configuration automatically, so you do not have to set it up manually.

What tags does Claude Code implement by default?

Claude Code implements whatever tags are in your tracking requirements document. It does not add tags you have not asked for. Common implementations include GA4 configuration, GA4 event tags (page_view, purchase, add_to_cart, form_submit, etc.), Google Ads conversion and remarketing tags, Meta Pixel, and LinkedIn Insight. You control the scope entirely.

Can I use this on an existing GTM container?

Yes. The workflow is designed for existing containers as well as new ones. The audit step is particularly valuable for containers that have been managed by multiple people over time - it surfaces conflicts, duplicates, and errors that are easy to miss in manual review. Claude Code is careful to preserve existing working tags and only modify what needs to be changed.

Want the automated version?

The Tag Manager Engine runs all 6 steps - audit, standardise, plan, implement, test, report - in a guided interface. The GTM skill is pre-loaded. No configuration required.

Open Tag Manager EngineGTM Automation overview