google-tag-manager
Google Tag Manager
Expert-level guidance for Google Tag Manager — auditing containers, designing tag and trigger architecture, debugging firing issues, implementing consent mode v2, and advising on server-side tagging.
Install
git clone https://github.com/thatrebeccarae/claude-marketing.git && cp -r claude-marketing/skills/google-tag-manager ~/.claude/skills/
Core Capabilities
Container Auditing and Optimization
Full container audit covering the six core areas: overview stats, tag inventory, trigger review, variable audit, folder organization, and naming convention assessment. Identifies unused tags, duplicate GA4 config tags, over-broad triggers on conversion tags, undefined variable paths, and consent mode gaps. Produces prioritized recommendations ranked by impact and effort.
Tag Architecture
Expert guidance on all common tag types:
- GA4 Configuration (
gaawc) — one per domain, holds measurement ID (always via constant variable), enhanced conversions settings, and shared config. All GA4 event tags must reference this as their Configuration Tag. - GA4 Event (
gaawe) — fires individual events with parameters sourced from data layer variables. References thegaawcconfig tag. - Google Ads Conversion Tracking — conversion ID + label, value and currency from data layer, deduplication tag ID for enhanced conversions.
- Google Ads Remarketing — conversion ID, custom parameters for audience building.
- Meta Pixel — base code + standard events (PageView, ViewContent, AddToCart, InitiateCheckout, Purchase). Use community template from Template Gallery rather than custom HTML.
- Custom HTML — unsandboxed JavaScript, creates CSP risk. Only use when no Template Gallery alternative exists.
- Community Templates — vetted third-party templates for Cookiebot, OneTrust, HotJar, Meta Pixel, LinkedIn Insight Tag, and more. Always prefer over Custom HTML.
Trigger Design
Matching triggers to tags with correct scoping is the single biggest factor in data quality. See REFERENCE.md for the full trigger type taxonomy. Key principles:
- Page Load triggers (Page View, DOM Ready, Window Loaded) for analytics tags that need the DOM
- Custom Event triggers for data layer events — exact match on event name
- Element Visibility for scroll depth and above-the-fold measurement
- Consent Initialization trigger for consent defaults — must fire before all measurement tags
- Never use All Pages trigger for conversion or remarketing tags
Variable Strategy
Data Layer Variables (v2) are the correct pattern for capturing tracking values. Key strategy:
- Use constant variables for all measurement IDs, API keys, and container IDs — one update propagates everywhere
- Data Layer Variables with dot-notation paths for nested ecommerce objects (
ecommerce.value,ecommerce.transaction_id) - Lookup Table variables for mapping internal category names to tracking values
- Custom JavaScript variables for derived values — note sandbox limitations (no DOM, no fetch, no async)
- Event Settings Variable to share a reusable set of GA4 event parameters across multiple event tags
Consent Mode v2
Four consent parameters control how Google tags behave when users deny consent:
analytics_storage— GA4, Google Analyticsad_storage— Google Ads cookie storagead_user_data— sending user data to Google Ads for matchingad_personalization— remarketing and personalization features
Advanced mode (recommended for DTC): Tags fire cookieless on deny, enabling Google's conversion modeling. Requires wait_for_update so the CMP has time to resolve user choice before tags fire.
Implementation sequence is order-sensitive — default consent must fire before any measurement tags load. See REFERENCE.md Consent Mode v2 section for full implementation details.
Server-Side GTM
Server-side GTM moves tag processing from the browser to a server container (GCP or alternative), improving data quality, blocking ad blocker impact, and enabling server enrichment. Key decision factors: ad blocker loss rate, privacy requirements, Meta CAPI needs, budget for hosting (~$30-50/mo on GCP), and technical capacity for setup.
The server container has no automatic access to browser consent state — consent must be explicitly passed from the browser in the request to the sGTM endpoint.
Debugging
- Preview mode — activates the GTM debugger in a paired browser tab. Left panel shows event timeline; right panel shows tag firing status, variable values, and data layer state at each event.
- Tag Assistant — integrated with GTM Preview. Consent tab shows consent parameter state at each event.
- Browser console —
window.dataLayerinspection, filter by event name - Network tab — GA4 collect requests, verify parameters, check
gcsparameter for consent state
Workflow: Full Container Audit
When asked to audit a GTM container:
-
Conversion Tracking Verification — Confirm GA4 config tag exists, measurement ID stored in a constant variable (not hardcoded), enhanced conversions enabled, Google Ads conversion tags present and correctly configured.
-
Tag Inventory — List all tags: name, type, status (paused/enabled), firing trigger, tag firing options (unlimited/once per page/once per event). Flag unused, paused, or duplicate tags.
-
Trigger Review — List all triggers with conditions. Flag any conversion or remarketing tag attached to an All Pages trigger. Check trigger conditions for URL specificity on conversion triggers.
-
Variable Audit — Confirm recommended built-in variables are enabled (Page URL, Page Path, Click Classes, Click ID, Form ID). Check all user-defined variables — are any returning undefined? Verify data layer variable paths match actual dataLayer push structure.
-
Organization Check — Is there a folder structure? Are workspaces named descriptively or all in "Default Workspace"? Review publish history — how many versions, how often, are descriptions informative?
-
Naming Convention Assessment — Do tag/trigger/variable names follow a consistent framework? Can a new team member understand the container? Flag inconsistency as a maintenance risk.
-
Consent Mode Check — Does a consent default tag exist firing on Consent Initialization? Is it configured with all four parameters? Does a CMP template exist? Is TCF v2.3 compatible? Verify in Preview mode Consent tab.
-
Prioritized Recommendations — Compile all findings. Rank by impact (revenue/data quality/compliance risk) and effort (Low/Medium/High). Lead with quick wins.
Hard Rules
Non-negotiable constraints in every recommendation:
- Never recommend DOM scraping when data layer is available. CSS selector or JS variable sniffing is fragile. Data layer is the contract between dev and analytics.
- Never recommend All Pages trigger for conversion tags. Conversion and remarketing tags on All Pages inflate costs and corrupt attribution.
- Never recommend Custom HTML when a community template exists. Community templates are sandboxed and vetted. Custom HTML runs unsandboxed and creates CSP/security risk.
- Always verify consent mode default fires before measurement tags load. Wrong initialization order means consent is not applied — a compliance failure.
- Always recommend constant variables for measurement IDs. Never hardcode a measurement ID, conversion ID, or API key directly in a tag. One update should propagate everywhere.
- Always flag deprecated Universal Analytics tags for removal. UA was fully sunsetted July 2024. Dead tags in a container are clutter and a warning sign about overall maintenance.
- Always clear previous ecommerce data before a new ecommerce push.
dataLayer.push({ ecommerce: null })before each push prevents data from a prior event contaminating the next. - Never skip workspace isolation. One change set per workspace. Never work in Default Workspace. Named workspaces with descriptive names are the expert standard.
Related Tools
google-analyticsskill — For GA4 data analysis after GTM implementation. GTM configures the tags; the google-analytics skill covers metrics, dimensions, reports, and attribution analysis on the data those tags collect.gtm-implementeragent — For writing GTM changes via the GTM API. Handles workspace preflight, rate-limited variable/trigger/tag creation, and payload construction. The google-tag-manager skill is the analysis layer; the gtm-implementer agent is the execution layer. When a user asks to implement GTM changes (not just audit or advise), point them to the agent.
How to Use This Skill
Ask questions like:
- "Audit our GTM container — we think some tags are not firing correctly"
- "Set up consent mode v2 in GTM with Cookiebot. We sell to EU customers."
- "Our GA4 purchase event is firing but transaction value shows as undefined in DebugView"
- "Should we go server-side with GTM? We are losing about 15% of data to ad blockers"
- "Review our naming conventions and tell me what needs to change"
- "Our conversion tags are firing on every page — help me scope them correctly"
- "What triggers should we use for a Shopify store with GA4, Google Ads, and Meta Pixel?"
- "Debug why our Add to Cart event stopped firing"
For complete tag type reference, trigger taxonomy, variable types, consent mode v2 parameters, sGTM architecture details, naming conventions, and anti-patterns, see REFERENCE.md.
For worked examples of container audits, consent mode setup, tag firing debug, and sGTM advisory, see EXAMPLES.md.
More from thatrebeccarae/claude-marketing
facebook-ads
Meta Ads (Facebook & Instagram) platform expertise. Audit campaigns, audiences, creative strategy, pixel tracking, and CAPI. Use when the user asks about Facebook Ads, Instagram Ads, Meta Ads, social media advertising, Advantage+ campaigns, or Meta pixel/CAPI setup.
13content-creator
Comprehensive content marketing toolkit with brand voice analysis, SEO optimization scripts, content frameworks, social media strategy, and content calendar planning. Use when writing blog posts, creating social media content, analyzing brand voice, optimizing SEO, planning content calendars, or developing content strategy. For deep SEO writing optimization, see the seo-content-writer skill.
13icp-research
Build detailed ideal customer profiles with pain points, objections, buying triggers, and messaging angles. Includes community research to find where ICPs gather online and extract their exact language. Use when researching audiences, creating buyer personas, or developing targeted messaging.
12content-pipeline
End-to-end content creation workflow that orchestrates research, editorial review, and social distribution agents in sequence. Use when the user wants to create, review, and distribute content through a multi-stage pipeline, or says "/content-pipeline".
12content-workflow
End-to-end content creation pipeline from research through editorial review to social distribution. Orchestrates a 3-stage workflow: research, draft/edit, and distribute. Supports blog posts, LinkedIn, Twitter threads, newsletters, and essays.
12brand-voice-guidelines
Develop brand voice, tone matrices, messaging frameworks, and brand book documentation. Use when the user asks about brand voice, tone of voice, brand guidelines, messaging framework, or brand consistency.
12