본문으로 건너뛰기
TakoAPI
스킬로 돌아가기

add-analytics

jeftekhari 제작

Data & Analytics
1.9kclawskills.sh가 보고한 다운로드 수
1스타
1조회수
좋아요 0개로그인하면 이 스킬에 좋아요를 누를 수 있습니다
—아직 평가 없음
내 평가

요약

Add Google Analytics 4 tracking to any project.

설명

이 스킬이 하는 일

Adds Google Analytics 4 tracking to a project by detecting the framework and inserting the appropriate gtag setup. Supports Next.js, Nuxt, Astro, SvelteKit, Remix, Gatsby, Vue, React (Vite/CRA), Angular, and plain HTML. Optional flags enable custom event helpers, cookie consent mode, and debug output.

Handles framework detection and generates the correct integration pattern automatically, avoiding the manual lookup and copy-paste errors that typically come with setting up gtag across different project types.

사용 시점

  • Adding GA4 to a Next.js app without manually writing gtag boilerplate
  • Setting up page-view tracking in a SvelteKit or Astro site
  • Adding cookie consent mode before launching to EU users
  • Instrumenting form submissions and purchase events with typed helpers
  • Configuring debug mode to verify tracking during development

예시 워크플로

입력

User asks: add analytics G-ABC1234567 --events --consent

에이전트
  1. 1

    Scans project files to detect framework (e.g., finds next.config.ts, identifies Next.js App Router)

  2. 2

    Validates measurement ID format matches G-XXXXXXXXXX

  3. 3

    Creates components/GoogleAnalytics.tsx with Script tags and injects it into app/layout.tsx

  4. 4

    Creates lib/analytics-events.ts with typed event helpers (trackClick, trackPurchase, etc.)

  5. 5

    Creates lib/analytics-consent.ts with consent mode defaults and updateConsent helpers

  6. 6

    Adds NEXT_PUBLIC_GA_MEASUREMENT_ID to .env.local and .env.example, ensures .env.local is in .gitignore

출력

GA4 tracking is live with consent mode defaulting to denied, event helpers exported and ready to use, and environment variable documented

요구 사항

  • Google Analytics 4 property with a Measurement ID (format: G-XXXXXXXXXX), obtained from analytics.google.com

설치

clawhub install jeftekhari/add-analytics

CLI 명령을 실행하거나, 프롬프트를 Claude Code, Cursor, Codex 등 사용하는 코딩 에이전트에 붙여넣으세요.

링크