Token导航 LogoToken导航

Agent Skill · 研究检索

gtm-testing(GTM 测试)

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

gtm-testing 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 38,637。

总安装 1,533周安装 62GitHub Stars 15下载 481核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:gtm-testing(GTM 测试)
来源仓库:https://github.com/aimonk2025/google-tag-manager-automation
仓库路径:skills/gtm-testing
安装命令:
npx skills add https://github.com/aimonk2025/google-tag-manager-automation --skill gtm-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/aimonk2025/google-tag-manager-automation --skill gtm-testing

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

gtm-testing 用于辅助测试设计、自动化测试和用例整理,提升软件质量保障能力。它适合编写单元测试、端到端测试和测试计划,支持回归验证。使用时需确认项目测试框架和运行命令,避免为了通过测试而破坏真实逻辑。涉及浏览器或外部服务时,应区分本地模拟与生产环境差异。

适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/gtm-testing

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/aimonk2025/google-tag-manager-automation --ski…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

gtm-testing 怎么安装?

在终端执行 npx skills add https://github.com/aimonk2025/google-tag-manager-automation --skill gtm-tes…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

gtm-testing 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

gtm-testing 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

gtm-testing 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

gtm-testing 用的人多吗?

公开数据是累计安装 1,533 次,近一周安装 62 次,下载 481 次,GitHub 15 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

gtm-testing 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
gtm-testing

GTM 测试 · 本页

1,53315操作浏览器未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

GTM Testing - Validation & Debugging

Guide users through comprehensive testing of GTM tracking implementation. Prefers automated headless testing over manual steps wherever possible.

Testing Philosophy

Four-tier validation approach, ordered by automation level:

  • Tier 0 (Automated): Playwright headless tests (no browser needed, fully automated)
  • Tier 1 (Manual): Browser Console dataLayer verification
  • Tier 2 (Manual): GTM Preview Mode tag firing verification
  • Tier 3 (Manual): GA4 DebugView end-to-end verification

Always start with Tier 0 if the user asks "can you do it yourself" or wants automated testing. Fall back to manual tiers only for GTM container and GA4 validation, which require a browser session.


Phase 0: Load Business Context (if available)

Check for gtm-context.md in the project root:

  • If found: read it silently and use the business context throughout this skill run (site type and known gaps help tailor which validation steps to emphasize)
  • If not found: proceed normally

This file is created automatically by gtm-analytics-audit at the end of its first run.


Tier 0: Automated Playwright Testing (Preferred)

Run this tier first. It requires no browser interaction from the user and can be run entirely by Claude.

Prerequisites Check

# Check if Playwright is installed
npx playwright --version

# If not installed as a project dependency:
npm install --save-dev playwright
npx playwright install chromium

# Check if dev server is running
curl -s -o /dev/null -w "%{http_code}" http://localhost:3000
# If not running, start it:
# npm run dev

Core Helper: captureDataLayerEvents

This helper intercepts all dataLayer.push() calls during an action and returns the captured events. Use it in every test.

async function captureDataLayerEvents(page, action) {
  await page.evaluate(() => {
    window.__testEvents = [];
    const original = window.dataLayer.push.bind(window.dataLayer);
    window.dataLayer.push = function (...args) {
      window.__testEvents.push(args[0]);
      return original(...args);
    };
  });

  await action();
  await page.waitForTimeout(300);

  return await page.evaluate(() => window.__testEvents || []);
}

Key Patterns for Common Element Types

Next.js Link components (navigation, course buttons): Do NOT use page.click() — it triggers navigation before the onClick handler fires. Use dispatchEvent instead:

await page.evaluate(() => {
  const btn = document.querySelector('a.js-module_nav');
  if (btn) btn.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
});
await page.waitForTimeout(400);

Outbound links (href to external domains): Block the navigation so the page stays loaded while the event fires:

await page.route('**github.com**', route => route.abort());
// Then use dispatchEvent as above

Regular buttons and internal actions: Standard click works fine:

await page.locator('#element-id').click({ force: true });

Test Script Template

Create scripts/test-tracking.js in the project root:

const { chromium } = require('playwright');

const BASE_URL = 'http://localhost:3000';
const results = { passed: [], failed: [], warnings: [] };

function pass(test, detail = '') {
  results.passed.push({ test, detail });
  console.log(`  PASS  ${test}${detail ? ' - ' + detail : ''}`);
}
function fail(test, detail = '') {
  results.failed.push({ test, detail });
  console.log(`  FAIL  ${test}${detail ? ' - ' + detail : ''}`);
}
function warn(test, detail = '') {
  results.warnings.push({ test, detail });
  console.log(`  WARN  ${test}${detail ? ' - ' + detail : ''}`);
}

async function captureDataLayerEvents(page, action) {
  await page.evaluate(() => {
    window.__testEvents = [];
    const original = window.dataLayer.push.bind(window.dataLayer);
    window.dataLayer.push = function (...args) {
      window.__testEvents.push(args[0]);
      return original(...args);
    };
  });
  await action();
  await page.waitForTimeout(300);
  return await page.evaluate(() => window.__testEvents || []);
}

async function runTests() {
  const browser = await chromium.launch({ headless: true });
  const context = await browser.newContext();

  console.log('\n=== GTM dataLayer Event Tests ===\n');

  // TEST: dataLayer initialisation
  console.log('Test: dataLayer initialisation');
  {
    const page = await context.newPage();
    await page.goto(BASE_URL, { waitUntil: 'networkidle' });
    const hasDataLayer = await page.evaluate(() => Array.isArray(window.dataLayer));
    hasDataLayer ? pass('dataLayer initialised') : fail('dataLayer not found');
    const gtmEvent = await page.evaluate(() => window.dataLayer.find(e => e['gtm.start']));
    gtmEvent ? pass('GTM bootstrap event present') : fail('GTM bootstrap event missing - container may not be installed');
    await page.close();
  }

  // TEST: cta_click event
  // Adjust selector to match your actual element ID
  console.log('\nTest: cta_click event');
  {
    const page = await context.newPage();
    await page.goto(BASE_URL, { waitUntil: 'networkidle' });
    const events = await captureDataLayerEvents(page, async () => {
      const el = await page.$('#your-cta-id');
      if (el) await page.evaluate(el => el.dispatchEvent(new MouseEvent('click', { bubbles: true })), el);
    });
    const e = events.find(e => e.event === 'cta_click');
    e ? pass('cta_click fired', `location=${e.cta_location}`) : fail('cta_click did not fire');
    await page.close();
  }

  // Add more tests following the same pattern...

  // RESULTS
  await browser.close();
  console.log('\n=== RESULTS ===');
  console.log(`  Passed:   ${results.passed.length}`);
  console.log(`  Failed:   ${results.failed.length}`);
  console.log(`  Warnings: ${results.warnings.length}`);
  if (results.failed.length > 0) {
    console.log('\nFailed:');
    results.failed.forEach(f => console.log(`  - ${f.test}: ${f.detail}`));
  }
  process.exit(results.failed.length > 0 ? 1 : 0);
}

runTests().catch(err => { console.error('Fatal:', err.message); process.exit(1); });

Finding Correct Element Selectors

Before writing tests, always inspect what's actually rendered. Use this discovery script:

// Add to test script or run as a separate debug script
const page = await context.newPage();
await page.goto(`${BASE_URL}/your-page`, { waitUntil: 'networkidle' });

const tracked = await page.evaluate(() => {
  return Array.from(document.querySelectorAll('[id], .js-track, [data-track]')).map(el => ({
    id: el.id,
    tag: el.tagName,
    class: el.className,
    text: el.textContent.trim().substring(0, 40),
    href: el.getAttribute('href'),
  }));
});
console.log(JSON.stringify(tracked, null, 2));

Validating GTM Container Configuration via API

Before running browser tests, verify the GTM container itself is correctly configured. This catches orphaned trigger references and missing measurement IDs.

// scripts/audit-gtm-coverage.js
// Uses googleapis + gtm-credentials.json + gtm-token.json + gtm-config.json

// Critical checks:
// 1. Base GA4 config tag (googtag) - must fire on Page View trigger
//    If firingTriggerId references a non-existent trigger, NO pages are tracked
// 2. GA4 event tags (gaawe) - must have measurementIdOverride set
//    Parameter key is "measurementIdOverride" NOT "measurementId"
// 3. All triggers must be used by at least one tag
// 4. All tags must have at least one firing trigger

Critical GTM API bug to watch for: The gaawe (GA4 Event) tag type uses measurementIdOverride and eventSettingsTable (not measurementId or eventParameters). The correct parameter structure is:

// CORRECT structure for gaawe tags via API
{
  type: 'gaawe',
  parameter: [
    { type: 'boolean', key: 'sendEcommerceData', value: 'false' },
    { type: 'template', key: 'eventName', value: 'your_event_name' },
    { type: 'template', key: 'measurementIdOverride', value: 'G-XXXXXXXXXX' },
    {
      type: 'list',
      key: 'eventSettingsTable',
      list: [
        {
          type: 'map',
          map: [
            { type: 'template', key: 'parameter', value: 'param_name' },
            { type: 'template', key: 'parameterValue', value: '{{DL - Variable Name}}' },
          ],
        },
      ],
    },
  ],
}

Running and Interpreting Results

node scripts/test-tracking.js

Exit code 0 = all tests passed. Exit code 1 = failures exist.

Result types:

  • PASS - Event fired with correct parameters
  • FAIL - Event did not fire, or required element not found
  • WARN - Component has tracking code but is not rendered on any page yet (not a bug)

Common failure causes and fixes:

FailureCauseFix
dataLayer not foundGTM snippet missing from <head>Add GTM container snippet to layout
Event didn't fireElement uses wrong selector in testUse discovery script to find real ID/class
Event fired but page unloadedClicking a Next.js <Link>Use dispatchEvent not page.click()
Outbound click not capturedPage navigated away before captureUse page.route() to block external navigation
No events on page loadGTM base tag has orphaned trigger referenceFix via GTM API or UI - re-assign to Page View trigger

Tier 1: Browser Console Testing (Manual)

Use when you want to manually verify events while interacting with the site.

Step 1: Check dataLayer Exists

window.dataLayer
// Expected: [...] array
// If undefined: GTM not installed

Step 2: Monitor dataLayer in Real-Time

const _push = window.dataLayer.push.bind(window.dataLayer);
window.dataLayer.push = function(...args) {
  console.log('%c dataLayer.push', 'background:#222;color:#0f0;padding:2px 6px', args[0]);
  return _push(...args);
};
// Now every push is logged in green

Step 3: Test Each Event

Click elements one at a time and verify the console output matches expected:

Expected for cta_click:
{
  event: "cta_click",
  cta_location: "hero",
  cta_type: "primary",
  cta_text: "Start Course",
  cta_destination: "/claude-code"
}

Validation Checklist - Tier 1

  • window.dataLayer is an array
  • GTM bootstrap event (gtm.start) present
  • Each event fires with correct event name
  • All required parameters present and non-empty
  • No duplicate events on single click
  • No JavaScript errors in console

Tier 2: GTM Preview Mode (Manual)

Confirms the GTM container receives events and fires tags. Requires GTM UI access.

Setup

  1. Go to tagmanager.google.com
  2. Select container
  3. Click Preview
  4. Enter site URL, click Connect
  5. A debug panel appears at the bottom of your site

What to Verify

For each event, the Preview panel should show:

Event fired: "cta_click"
  Triggers: CE - CTA Click  [FIRED]
  Tags:      GA4 - CTA Click [FIRED]

Click a fired tag to verify:

  • measurementIdOverride has the correct GA4 ID
  • All event parameters are populated (not empty {{DL -...}} strings)

Validation Checklist - Tier 2

  • Preview mode connects successfully
  • GA4 Configuration tag fires on page load (not orphaned)
  • Each custom event appears in the event list
  • Correct trigger fires for each event
  • Correct tag fires for each trigger
  • Tag parameters show resolved values (not unresolved variable references)
  • No tags firing unexpectedly

Tier 3: GA4 DebugView (Manual)

Confirms events reach GA4 with correct parameters. Requires GA4 property access.

Enable Debug Mode

Option A - URL parameter: append ?debug_mode=true to the page URL

Option B - Chrome extension: install Google Analytics Debugger, enable it

Open DebugView

GA4 > Admin > Property > DebugView

Events appear in real time as you interact with the site.

What to Verify

  • Event name appears (e.g., cta_click)
  • All parameters visible with correct values
  • page_view event fires on every page navigation
  • Event count increments on repeated actions

Validation Checklist - Tier 3

  • page_view events firing on all pages
  • Custom events appear within 1-3 seconds of firing
  • All event parameters visible and correctly valued
  • Events attributed to correct page paths
  • No unexpected events

Common Issues Reference

IssueTier FoundCauseFix
dataLayer undefined1GTM snippet missingAdd GTM snippet to <head>
Event fires, trigger doesn't2Event name mismatch (case-sensitive)Confirm trigger uses {{_event}} equals exact event name
Trigger fires, tag doesn't2Orphaned trigger or misconfigured tagCheck tag has valid firing trigger assigned
Page View tag never fires2Orphaned trigger reference on base tagRe-assign base tag to a valid Page View trigger
Parameters show as {{DL - X}}2Data Layer Variable not createdCreate DLV with correct dataLayer key name
Events in Preview, not DebugView3Wrong GA4 property or debug mode offVerify Measurement ID matches, enable debug mode
Parameters missing in GA43Not mapped in tag's eventSettingsTableAdd parameter mapping in GTM tag config

Full Workflow

1. Run Tier 0 (automated)
   PASS → proceed to publish GTM
   FAIL → fix code or GTM config, re-run

2. Run Tier 1 (console) — optional manual spot-check
   PASS → proceed
   FAIL → fix before Tier 2

3. Run Tier 2 (GTM Preview)
   PASS → proceed
   FAIL → fix GTM tags/triggers/variables

4. Run Tier 3 (GA4 DebugView)
   PASS → publish GTM container
   FAIL → fix GA4 config or parameter mappings

5. Publish GTM → GTM UI > Submit > Publish version
6. Disable debug mode in production
7. Monitor GA4 Reports > Engagement > Events

References

  • references/debugging-guide.md - Extended issue diagnosis
  • references/test-checklist.md - Printable checklist template
  • examples/sample.md - Example test run output showing PASS/FAIL/WARN format and common failure fixes
  • Related skills: gtm-implementation, gtm-analytics-audit, gtm-reporting

平台分布

Codex

35.01%
按下载量换算168

Claude

31.83%
按下载量换算153

Cursor

17.53%
按下载量换算84

Gemini CLI

10.11%
按下载量换算49

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills