Files
our-claude-skills/.claude/commands/gtm-editor.md
Andrew Yim c35a28780d feat(gtm): add mandatory knowledge-base read/write directives to GTM skills
Agents must now read client profiles before GTM work and write session
logs after completing audits, tag changes, or validation — ensuring
findings compound across sessions instead of being lost.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 00:03:27 +09:00

3.1 KiB

description
description
GTM tag/trigger/variable creation via API with ES5 Custom HTML and dataLayer code generation

GTM Editor

Create, modify, and deploy GTM configurations via API. Generates ES5-compliant Custom HTML tags.

Pre-Flight

BEFORE any API write operation, read the relevant gotcha files at: ~/Project/dintel-gtm-agent/docs/log/gotcha/ (see README.md for index)

Priority reads per task:

  • Creating triggersgotcha/triggers.md (scrollDepth/timer limits, negate placement, naming)
  • Creating variablesgotcha/variables.md (RegEx Table column names)
  • Writing regex conditionsgotcha/regex.md (RE2 limitations)
  • Batch changes / publishinggotcha/compilation.md (workspace lifecycle)
  • Using DTM CLIgotcha/dtm-cli.md (commands that don't actually work)

Triggers

  • "create GTM tag", "generate dataLayer", "modify trigger"
  • "update variable", "write custom HTML", "manage GTM"

MANDATORY: Knowledge Base Read/Write

Before creating or modifying ANY tags, triggers, or variables:

  1. Identify the target client from container ID
  2. Read knowledge-base/accounts/<client>/profile.md — key variables, URL patterns, platform stack, known issues
  3. Read knowledge-base/accounts/<client>/*.md — taxonomy reveals existing event names and naming conventions
  4. Skim knowledge-base/logs/<client>/ — past fixes reveal patterns (e.g., "form POST loses URL params")

After completing tag management, write a session log:

  • Write to knowledge-base/logs/<client>/YYYY-MM-DD-<description>.md
  • Include: date, container ID, tags affected (IDs), what was created/modified/deleted, cHTML snippets
  • Update knowledge-base/accounts/<client>/profile.md if you discovered persistent facts
  • See AGENTS.md for full format template

MANDATORY: dataLayer First Workflow

  1. Design dataLayer push FIRST (match client's tech stack: vanilla JS/React/Vue/PHP)
  2. Ask user: "Can your devs add this to the page?"
  3. Create simple GTM config: Custom Event trigger + DLV variables + GA4 Event tag
  4. cHTML fallback LAST RESORT: Only if user cannot modify website code

Key Rules

  • Always use measurementIdOverride for GA4 event tags (NOT measurementId)
  • Always prefer element IDs for triggers -- ask user to add IDs before CSS selectors
  • All Custom HTML must be ES5-compatible (no arrow functions, const/let, template literals)
  • Use dtm_status first to verify auth and active container

Trigger Design Priority

  1. Element ID (Click ID equals "hero-btn-consult")
  2. Data attribute ([data-track="consult"])
  3. Form ID (Form ID equals "contact-form")
  4. CSS selector (last resort -- document which selectors)

Supported Tag Types

  • googtag (GA4 config), gaawe (GA4 events), awct (Ads conversion)
  • html (Custom HTML for Meta, PostHog, Kakao), gclidw (Conversion Linker)

Korean Market Patterns

  • Currency: KRW (no decimals)
  • Payment buttons: 장바구니, 결제하기, 문의하기
  • Platforms: Kakao Pixel, Naver Analytics

Workflow

  1. Analyze (Chrome DevTools) -> 2. Design events -> 3. Create via DTM Agent -> 4. Hand to gtm-validator -> 5. Document in Notion