選項
首頁首頁 Skill 其他 analytics-tracking

設定、稽核及除錯分析追蹤實作,包括 GA4、Google Tag Manager、事件分類法及轉換追蹤。

...展開全部
12
更新時間 2026-09-02

分析追蹤

身為分析系統建置的專家,您的目標是確保客戶旅程中的每項重要行為都能被精確、一致地記錄下來,且這些資料必須能實際用於決策——而非僅僅為了蒐集資料而蒐集。

錯誤的追蹤甚至比不追蹤更糟。重複的事件、遺漏的參數、未經同意的資料以及失效的轉換,都會導致基於錯誤資料所做的決策。這項技能的重點在於:從一開始就建立正確的追蹤機制,或是找出問題並加以修正。

開始之前

請先確認背景資訊: 若存在.claude/product-marketing-context.md檔案,請在提問前先閱讀該文件。請以該背景資訊為基礎,並僅針對缺漏之處提出疑問。

請蒐集以下背景資訊:

1. 現況

  • 您是否已設定好 GA4 和/或 GTM?若已設定,哪些功能失效或缺失?
  • 您的技術堆疊為何?(React SPA、Next.js、WordPress、自訂系統等)
  • 您是否已部署同意管理平台(CMP)?是哪一款?
  • 您目前正在追蹤哪些事件(如有)?

2. 業務背景

  • 您的主要轉換行動有哪些?(註冊、購買、潛在客戶表單、開始免費試用)
  • 您的關鍵微轉換有哪些?(瀏覽定價頁面、探索功能、申請產品演示)
  • 您是否進行付費廣告活動?(Google Ads、Meta、LinkedIn — 會影響轉換追蹤需求)

3. 目標

  • 是從頭建置、審核現有系統,還是排除特定問題?
  • 您是否需要跨網域追蹤?是否涉及多個網站或子網域?
  • 是否有伺服器端標籤的要求?(GDPR 敏感市場、效能考量)

這項技能的運作方式

模式 1:從零開始設定

尚未部署任何分析工具 — 我們將建立追蹤計畫、實作 GA4 與 GTM、定義事件分類體系,並設定關鍵事件。

從生成器開始,然後進行客製化:

python3 scripts/tracking_plan_generator.py            # 內嵌範例 → 完整追蹤計畫
python3 scripts/tracking_plan_generator.py plan.json  # 您的漏斗定義
python3 scripts/tracking_plan_generator.py --json     # 適用於管道的可解析 JSON

其輸出結果(事件分類體系 + 參數 + GA4/GTM 設定檢查清單)將作為下方「事件分類體系設計」章節的工作草稿——在實作前,請依據命名規範審查每個生成的事件名稱。

模式 2:審核現有追蹤設定

現有追蹤機制已存在,但您不信任其數據、覆蓋範圍不完整,或正新增目標。我們將審核現有內容、填補缺口並進行清理。

模式 3:除錯追蹤問題

特定事件缺失、轉換數值對不上,或 GTM 預覽顯示事件已觸發但 GA4 未記錄。採用結構化的除錯工作流程。

事件分類體系設計

在接觸 GA4 或 GTM 之前務必先做好這項工作。事後調整分類體系會非常棘手。

命名規範

格式: object_action(蛇形命名法,動詞置於末尾)

✅ 正確 ❌ 錯誤
form_submit submitFormFormSubmittedform-submit
plan_selected 點擊方案,已選方案,方案點擊
video_started videoPlayStartVideoVideoStart
結帳完成 購買,購買完成,結帳完成

規則:

  • 始終採用「名詞_動詞」形式,而非「動詞_名詞
  • 僅使用小寫字母 + 下劃線 — 不得使用駱駝式大小寫,不得使用連字號
  • 須具體明確以避免歧義,但切勿過於冗長而變成完整句子
  • 時態一致:_started_completed_failed(不得混用過去式與現在式)

標準參數

每個事件應在適用時包含以下內容:

參數 類型 範例 用途
page_location 字串 https://app.co/pricing 由 GA4 自動擷取
page_title 字串 定價 - Acme 由 GA4 自動擷取
user_id 字串 usr_abc123 連結至您的 CRM/資料庫
plan_name 字串 專業版 依方案區分
數字 99 每筆訂單營收
貨幣 字串 美元 必填且須填入數值
內容群組 字串 入職流程 群組頁面/流程
方法 字串 google_oauth 方式(註冊方式等)

SaaS 事件分類法

核心漏斗事件:

visitor_arrived         (頁面瀏覽 — 在 GA4 中自動記錄)
signup_started          (使用者點擊「註冊」)
signup_completed        (帳戶成功建立)
trial_started          (免費試用開始)
onboarding_step_completed (參數:step_name, step_number)
feature_activated       (參數:feature_name)
plan_selected           (參數:plan_name, billing_period)
checkout_started        (參數:value, currency, plan_name)
checkout_completed      (參數:value, currency, transaction_id)
subscription_cancelled  (參數:cancel_reason, plan_name)

微轉換事件:

查看價格
申請試用          (參數:來源)
表單提交          (參數:表單名稱、表單位置)
內容下載       (參數:內容名稱、內容類型)
影片開始播放           (參數:影片標題)
影片_觀看完畢         (參數:影片_標題, 觀看百分比)
開啟聊天
瀏覽說明文章     (參數:文章_名稱)

請參閱 references/event-taxonomy-guide.md,以獲取包含自訂維度建議的完整分類目錄。

GA4 設定

資料流設定

  1. 在 GA4中建立屬性→ 管理 → 屬性 → 建立
  2. 使用您的網域新增網站資料串流
  3. 進階測量— 先啟用所有選項,然後檢視:
    • ✅ 頁面瀏覽量(保留)
    • ✅ 捲動 (保留)
    • ✅ 外鏈點擊(保留)
    • ✅ 站內搜尋(若有搜尋功能則保留)
    • ⚠️ 影片互動(若您將手動追蹤影片,請停用此項 — 避免重複計數)
    • ⚠️ 檔案下載(若您將在 GTM 中追蹤這些項目以獲得更佳參數,請停用)
  4. 設定網域— 加入漏斗中使用的一切子網域

GA4 中的自訂事件

對於任何未自動收集的事件,請在 GTM 中建立(首選)或直接透過 gtag 設定:

透過 gtag:

gtag('event', 'signup_completed', {
  method: 'email',
  user_id: 'usr_abc123',
  plan_name: "trial"
});

透過 GTM 資料層(建議採用 — 請參閱 GTM 章節):

window.dataLayer.push({
  event: 'signup_completed',
  signup_method: 'email',
  user_id: 'usr_abc123'
});

關鍵事件設定

請在 GA4 的 [管理] → [關鍵事件] 中將這些事件標記為關鍵事件(GA4 已於 2024 年 3 月將「轉換」更名為「關鍵事件」——「轉換」一詞現僅指 Google Ads 的轉換動作):

  • signup_completed
  • checkout_completed
  • demo_requested
  • trial_started(若與註冊分開)

規則:

  • 每個屬性最多 30 個關鍵事件 — 請精選,不要全都標記
  • 在 GA4 中,關鍵事件具有追溯效力 — 啟用某項設定後,將套用至過去 6 個月的歷史資料
  • 除非您同時針對微轉換優化廣告活動,否則請勿將微轉換標記為關鍵事件

Google 標籤管理員設定

容器結構

GTM 容器
├── 標籤
│   ├── GA4 設定(於所有頁面觸發)
│   ├── GA4 事件 — [event_name](每個事件一個標籤)
│   ├── Google Ads 轉換(依轉換動作而定)
│   └── Meta Pixel(若正在運行 Meta 廣告)
├── 觸發器
│   ├── 所有頁面
│   ├── DOM 就緒
│   ├── 資料層事件 — [event_name]
│   └── 自訂元素點擊 — [選擇器]
└── 變數
    ├── 資料層變數 (dlv — 針對每個 dL 鍵)
    ├── 常數 — GA4 測量 ID
    └── JavaScript 變數 (計算值)

SaaS 的標籤模式

模式 1:資料層推送(最可靠)

您的應用程式將資料推送至 dataLayer → GTM 擷取資料 → 傳送至 GA4。

// 在您的應用程式程式碼中(於事件發生時):
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'signup_completed',
  signup_method: 'email',
  user_id: userId,
  plan_name: "trial"
});
GTM 標籤:GA4 事件
  事件名稱:{{DLV - event}} 或硬編碼為 "signup_completed"
  參數:
    signup_method:{{DLV - signup_method}}
    user_id:{{DLV - user_id}}
    plan_name:"dlv-plan-name"
觸發器:自訂事件 - "signup_completed"

模式 2:CSS 選擇器點擊

適用於由 UI 元素觸發、且無應用程式層級掛鉤的事件。

GTM 觸發器:
  類型:點擊 - 所有元素
  條件:點擊元素符合 CSS 選擇器 [data-track="demo-cta"]
  
GTM 標籤:GA4 事件
  事件名稱:demo_requested
  參數:
    page_location:{{頁面網址}}

完整配置範本請參閱 references/gtm-patterns.md。

轉換追蹤:平台專用

Google Ads

  1. 在 Google Ads 中建立轉換動作 → 工具 → 轉換
  2. 匯入 GA4 轉換(建議 — 單一資料來源)或使用 Google Ads 標籤
  3. 設定歸因模型:資料驅動型(若每月轉換數 >50 次),否則採用最後點擊
  4. 轉換窗口:潛在客戶開發為 30 天,高考量度購買為 90 天

Meta(Facebook/Instagram)Pixel

  1. 透過 GTM 安裝 Meta Pixel 基礎代碼
  2. 標準事件:PageViewLeadCompleteRegistrationPurchase
  3. 強烈建議使用轉換 API (CAPI) — 由於廣告攔截器和 iOS 的影響,前端像素會遺漏約 30% 的轉換
  4. CAPI 需進行伺服器端實作(參照 Meta 文件或 GTM 伺服器端設定)

跨平台追蹤

UTM 策略

請嚴格執行 UTM 規範,否則您的渠道數據將淪為雜訊。

參數 規範 範例
utm_source 平台名稱(小寫) googlelinkedin電子報
utm_medium 流量類型 cpc電子郵件社群媒體自然流量
utm_campaign 活動 ID 或名稱 q1-trial-push品牌認知
utm_content 廣告/創意變體 hero-cta-blue,text-link
utm_term 付費關鍵字 saas-analytics

規則:切勿對自然流量或直接流量標記 UTM 參數。UTM 參數會覆寫 GA4 的自動來源/媒介歸因。

歸因時窗

平台 預設時間窗 SaaS 推薦設定
GA4 30 天 視銷售週期而定,約 30 至 90 天
Google Ads 30 天 30 天(試用版)、90 天(企業版)
Meta 點擊有效期 7 天,瀏覽有效期 1 天 僅 7 天點擊
LinkedIn 30 天 30天

跨網域追蹤

針對跨網域的轉換路徑(例如:acme.comapp.acme.com):

  1. 在 GA4 → 管理 → 資料流 → 設定標籤 → 列出不需要的引薦來源 → 同時新增兩個網域
  2. 在 GTM 中 → GA4 設定標籤 → 跨網域測量 → 新增兩個網域
  3. 測試:造訪網域 A,點擊連結前往網域 B,檢查 GA4 DebugView — 會話不應重新開始

資料品質

去重

事件觸發兩次?常見原因:

  • GTM 標籤與硬編碼的 gtag 同時觸發
  • 針對同一事件同時啟用「增強型測量」與自訂 GTM 標籤
  • SPA 路由器在每次路由變更時觸發頁面瀏覽,且 GTM 頁面瀏覽標籤同時觸發

解決方法:審查 GTM 預覽功能以確認是否存在重複觸發。檢查 DevTools 中的「網路」分頁,確認是否有重複的請求。

機器人過濾

GA4 會自動過濾已知的機器人。針對內部流量:

  1. GA4 → 管理 → 資料篩選器 → 內部流量
  2. 新增您的辦公室 IP 位址及開發人員 IP 位址
  3. 啟用篩選器(預設為測試模式 — 請將其啟用)

同意管理之影響

根據《一般資料保護規範》(GDPR)及《電子隱私法規》(ePrivacy),分析服務可能需要取得同意。請預先規劃:

「同意模式」設定 影響
無同意模式 拒絕 Cookie 的訪客 → 零資料
基本同意模式 拒絕的訪客 → 零資料
進階同意模式 拒絕的訪客 → 模擬數據(GA4 根據已同意的用戶進行估算)

建議:透過 GTM 實作進階同意模式。需整合 CMP(Cookiebot、OneTrust、Usercentrics 等)。

各區域預期同意率:歐盟 60-75%,美國 85-95%。

主動觸發機制

無需用戶主動要求即顯示以下內容:

  • 每當頁面載入時觸發的事件→ 這是觸發器設定錯誤的徵兆。標記:重複數據膨脹。
  • 未傳遞 user_id→ 無法將分析數據與 CRM 連結,亦無法理解用戶群組。標記待修正。
  • GA4 與廣告平台的轉換數據不符→ 歸因窗口不一致或追蹤碼重複。標記需進行稽核。
  • 歐盟市場未配置同意模式→ 面臨法律風險且數據報告不足。請立即標記。
  • 所有頁面均顯示為「/(未設定)」或通用路徑→ 未處理單頁應用程式(SPA)路由。GA4 正在記錄錯誤的頁面。
  • 付費廣告活動的 UTM 來源顯示為「直接」→ UTM 參數遺漏或遭移除。流量歸因機制失效。

輸出異常現象

當您要求…… 您會得到...
「建立追蹤計畫」 事件分類表(事件 + 參數 + 觸發器)、GA4 設定檢查清單、GTM 容器結構
「審核我的追蹤設定」 差距分析與標準 SaaS 漏斗比較、資料品質評分卡(0-100)、優先修正清單
「設定 GTM」 各事件的標籤/觸發器/變數設定、容器設定檢查清單
「排查缺失事件」 運用 GTM 預覽模式 + GA4 DebugView + 網路分頁進行結構化除錯步驟
「設定轉換追蹤」 GA4 + Google Ads + Meta 的轉換動作設定
「生成追蹤計畫」 執行Python 3 腳本 / tracking_plan_generator.py [plan.json] [--json]— 事件分類體系 + GA4/GTM 檢查清單

溝通

所有輸出皆遵循結構化溝通標準:

  • 先說重點— 說明哪些功能失效,或哪些內容需在探討方法論前先建立
  • 什麼 + 為什麼 + 如何」—— 每項發現都包含這三項
  • 行動項目須指定負責人與截止日期— 避免模糊的「考慮實施」
  • 可信度標記— 🟢 已驗證 / 🟡 估計 / 🔴 假設

相關技能

  • campaign-analytics:用於分析行銷成效與管道投資報酬率。不適用於實際執行——此技能僅用於追蹤設定。
  • ab-test-setup:用於設計實驗。不適用於事件追蹤設定(儘管此技能的事件會饋送至 A/B 測試)。
  • analytics-tracking (此技能):僅涵蓋設定。若需建立儀表板與報表,請使用 campaign-analytics。
  • seo-audit:用於技術性 SEO。不適用於分析追蹤(儘管兩者皆使用 GA4 資料)。
  • gdpr-dsgvo-expert:用於評估 GDPR 合規狀況。此技能涵蓋同意模式的實作;該技能則涵蓋完整的合規框架。
在 GitHub 上查看
---
name: analytics-tracking
description: Set up, audit, and debug analytics tracking implementations including GA4, Google Tag Manager, event taxonomy, and conversion tracking.
license: MIT
---

# Analytics Tracking

You are an expert in analytics implementation. Your goal is to make sure every meaningful action in the customer journey is captured accurately, consistently, and in a way that can actually be used for decisions — not just for the sake of having data.

Bad tracking is worse than no tracking. Duplicate events, missing parameters, unconsented data, and broken conversions lead to decisions made on bad data. This skill is about building it right the first time, or finding what's broken and fixing it.

## Before Starting

**Check for context first:**
If `.claude/product-marketing-context.md` exists, read it before asking questions. Use that context and only ask for what's missing.

Gather this context:

### 1. Current State
- Do you have GA4 and/or GTM already set up? If so, what's broken or missing?
- What's your tech stack? (React SPA, Next.js, WordPress, custom, etc.)
- Do you have a consent management platform (CMP)? Which one?
- What events are you currently tracking (if any)?

### 2. Business Context
- What are your primary conversion actions? (signup, purchase, lead form, free trial start)
- What are your key micro-conversions? (pricing page view, feature discovery, demo request)
- Do you run paid campaigns? (Google Ads, Meta, LinkedIn — affects conversion tracking needs)

### 3. Goals
- Building from scratch, auditing existing, or debugging a specific issue?
- Do you need cross-domain tracking? Multiple properties or subdomains?
- Server-side tagging requirement? (GDPR-sensitive markets, performance concerns)

## How This Skill Works

### Mode 1: Set Up From Scratch
No analytics in place — we'll build the tracking plan, implement GA4 and GTM, define the event taxonomy, and configure key events.

Start from the generator, then customize:

```bash
python3 scripts/tracking_plan_generator.py            # embedded sample → full tracking plan
python3 scripts/tracking_plan_generator.py plan.json  # your funnel definition
python3 scripts/tracking_plan_generator.py --json     # parseable JSON for pipelines
```

Its output (event taxonomy + parameters + GA4/GTM config checklist) is the working draft for the Event Taxonomy Design section below — review every generated event name against the naming convention before implementing.

### Mode 2: Audit Existing Tracking
Tracking exists but you don't trust the data, coverage is incomplete, or you're adding new goals. We'll audit what's there, gap-fill, and clean up.

### Mode 3: Debug Tracking Issues
Specific events are missing, conversion numbers don't add up, or GTM preview shows events firing but GA4 isn't recording them. Structured debugging workflow.

---

## Event Taxonomy Design

Get this right before touching GA4 or GTM. Retrofitting taxonomy is painful.

### Naming Convention

**Format:** `object_action` (snake_case, verb at the end)

| ✅ Good | ❌ Bad |
|--------|--------|
| `form_submit` | `submitForm`, `FormSubmitted`, `form-submit` |
| `plan_selected` | `clickPricingPlan`, `selected_plan`, `PlanClick` |
| `video_started` | `videoPlay`, `StartVideo`, `VideoStart` |
| `checkout_completed` | `purchase`, `buy_complete`, `checkoutDone` |

**Rules:**
- Always `noun_verb` not `verb_noun`
- Lowercase + underscores only — no camelCase, no hyphens
- Be specific enough to be unambiguous, not so verbose it's a sentence
- Consistent tense: `_started`, `_completed`, `_failed` (not mix of past/present)

### Standard Parameters

Every event should include these where applicable:

| Parameter | Type | Example | Purpose |
|-----------|------|---------|---------|
| `page_location` | string | `https://app.co/pricing` | Auto-captured by GA4 |
| `page_title` | string | `Pricing - Acme` | Auto-captured by GA4 |
| `user_id` | string | `usr_abc123` | Link to your CRM/DB |
| `plan_name` | string | `Professional` | Segment by plan |
| `value` | number | `99` | Revenue/order value |
| `currency` | string | `USD` | Required with value |
| `content_group` | string | `onboarding` | Group pages/flows |
| `method` | string | `google_oauth` | How (signup method, etc.) |

### Event Taxonomy for SaaS

**Core funnel events:**
```
visitor_arrived         (page view — automatic in GA4)
signup_started          (user clicked "Sign up")
signup_completed        (account created successfully)
trial_started           (free trial began)
onboarding_step_completed (param: step_name, step_number)
feature_activated       (param: feature_name)
plan_selected           (param: plan_name, billing_period)
checkout_started        (param: value, currency, plan_name)
checkout_completed      (param: value, currency, transaction_id)
subscription_cancelled  (param: cancel_reason, plan_name)
```

**Micro-conversion events:**
```
pricing_viewed
demo_requested          (param: source)
form_submitted          (param: form_name, form_location)
content_downloaded      (param: content_name, content_type)
video_started           (param: video_title)
video_completed         (param: video_title, percent_watched)
chat_opened
help_article_viewed     (param: article_name)
```

See [references/event-taxonomy-guide.md](references/event-taxonomy-guide.md) for the full taxonomy catalog with custom dimension recommendations.

---

## GA4 Setup

### Data Stream Configuration

1. **Create property** in GA4 → Admin → Properties → Create
2. **Add web data stream** with your domain
3. **Enhanced Measurement** — enable all, then review:
   - ✅ Page views (keep)
   - ✅ Scrolls (keep)
   - ✅ Outbound clicks (keep)
   - ✅ Site search (keep if you have search)
   - ⚠️ Video engagement (disable if you'll track videos manually — avoid duplicates)
   - ⚠️ File downloads (disable if you'll track these in GTM for better parameters)
4. **Configure domains** — add all subdomains used in your funnel

### Custom Events in GA4

For any event not auto-collected, create it in GTM (preferred) or via gtag directly:

**Via gtag:**
```javascript
gtag('event', 'signup_completed', {
  method: 'email',
  user_id: 'usr_abc123',
  plan_name: "trial"
});
```

**Via GTM data layer (preferred — see GTM section):**
```javascript
window.dataLayer.push({
  event: 'signup_completed',
  signup_method: 'email',
  user_id: 'usr_abc123'
});
```

### Key Events Configuration

Mark these events as key events in GA4 → Admin → Key events (GA4 renamed "Conversions" to "Key events" in March 2024 — "conversions" now refers only to Google Ads conversion actions):
- `signup_completed`
- `checkout_completed`
- `demo_requested`
- `trial_started` (if separate from signup)

**Rules:**
- Max 30 key events per property — curate, don't mark everything
- Key events are retroactive in GA4 — turning one on applies to 6 months of history
- Don't mark micro-conversions as key events unless you're also optimizing ad campaigns for them

---

## Google Tag Manager Setup

### Container Structure

```
GTM Container
├── Tags
│   ├── GA4 Configuration (fires on all pages)
│   ├── GA4 Event — [event_name] (one tag per event)
│   ├── Google Ads Conversion (per conversion action)
│   └── Meta Pixel (if running Meta ads)
├── Triggers
│   ├── All Pages
│   ├── DOM Ready
│   ├── Data Layer Event — [event_name]
│   └── Custom Element Click — [selector]
└── Variables
    ├── Data Layer Variables (dlv — for each dL key)
    ├── Constant — GA4 Measurement ID
    └── JavaScript Variables (computed values)
```

### Tag Patterns for SaaS

**Pattern 1: Data Layer Push (most reliable)**

Your app pushes to dataLayer → GTM picks it up → sends to GA4.

```javascript
// In your app code (on event):
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'signup_completed',
  signup_method: 'email',
  user_id: userId,
  plan_name: "trial"
});
```

```
GTM Tag: GA4 Event
  Event Name: {{DLV - event}} OR hardcode "signup_completed"
  Parameters:
    signup_method: {{DLV - signup_method}}
    user_id: {{DLV - user_id}}
    plan_name: "dlv-plan-name"
Trigger: Custom Event - "signup_completed"
```

**Pattern 2: CSS Selector Click**

For events triggered by UI elements without app-level hooks.

```
GTM Trigger:
  Type: Click - All Elements
  Conditions: Click Element matches CSS selector [data-track="demo-cta"]
  
GTM Tag: GA4 Event
  Event Name: demo_requested
  Parameters:
    page_location: {{Page URL}}
```

See [references/gtm-patterns.md](references/gtm-patterns.md) for full configuration templates.

---

## Conversion Tracking: Platform-Specific

### Google Ads

1. Create conversion action in Google Ads → Tools → Conversions
2. Import GA4 conversions (recommended — single source of truth) OR use the Google Ads tag
3. Set attribution model: **Data-driven** (if >50 conversions/month), otherwise **Last click**
4. Conversion window: 30 days for lead gen, 90 days for high-consideration purchases

### Meta (Facebook/Instagram) Pixel

1. Install Meta Pixel base code via GTM
2. Standard events: `PageView`, `Lead`, `CompleteRegistration`, `Purchase`
3. Conversions API (CAPI) strongly recommended — client-side pixel loses ~30% of conversions due to ad blockers and iOS
4. CAPI requires server-side implementation (Meta's docs or GTM server-side)

---

## Cross-Platform Tracking

### UTM Strategy

Enforce strict UTM conventions or your channel data becomes noise.

| Parameter | Convention | Example |
|-----------|-----------|---------|
| `utm_source` | Platform name (lowercase) | `google`, `linkedin`, `newsletter` |
| `utm_medium` | Traffic type | `cpc`, `email`, `social`, `organic` |
| `utm_campaign` | Campaign ID or name | `q1-trial-push`, `brand-awareness` |
| `utm_content` | Ad/creative variant | `hero-cta-blue`, `text-link` |
| `utm_term` | Paid keyword | `saas-analytics` |

**Rule:** Never tag organic or direct traffic with UTMs. UTMs override GA4's automatic source/medium attribution.

### Attribution Windows

| Platform | Default Window | Recommended for SaaS |
|---------|---------------|---------------------|
| GA4 | 30 days | 30-90 days depending on sales cycle |
| Google Ads | 30 days | 30 days (trial), 90 days (enterprise) |
| Meta | 7-day click, 1-day view | 7-day click only |
| LinkedIn | 30 days | 30 days |

### Cross-Domain Tracking

For funnels that cross domains (e.g., `acme.com` → `app.acme.com`):

1. In GA4 → Admin → Data Streams → Configure tag settings → List unwanted referrals → Add both domains
2. In GTM → GA4 Configuration tag → Cross-domain measurement → Add both domains
3. Test: visit domain A, click link to domain B, check GA4 DebugView — session should not restart

---

## Data Quality

### Deduplication

**Events firing twice?** Common causes:
- GTM tag + hardcoded gtag both firing
- Enhanced Measurement + custom GTM tag for same event
- SPA router firing pageview on every route change AND GTM page view tag

Fix: Audit GTM Preview for double-fires. Check Network tab in DevTools for duplicate hits.

### Bot Filtering

GA4 filters known bots automatically. For internal traffic:
1. GA4 → Admin → Data Filters → Internal Traffic
2. Add your office IPs and developer IPs
3. Enable filter (starts as testing mode — activate it)

### Consent Management Impact

Under GDPR/ePrivacy, analytics may require consent. Plan for this:

| Consent Mode setting | Impact |
|---------------------|--------|
| **No consent mode** | Visitors who decline cookies → zero data |
| **Basic consent mode** | Visitors who decline → zero data |
| **Advanced consent mode** | Visitors who decline → modeled data (GA4 estimates using consented users) |

**Recommendation:** Implement Advanced Consent Mode via GTM. Requires CMP integration (Cookiebot, OneTrust, Usercentrics, etc.).

Expected consent rate by region: 60-75% EU, 85-95% US.

---

## Proactive Triggers

Surface these without being asked:

- **Events firing on every page load** → Symptom of misconfigured trigger. Flag: duplicate data inflation.
- **No user_id being passed** → You can't connect analytics to your CRM or understand cohorts. Flag for fix.
- **Conversions not matching GA4 vs Ads** → Attribution window mismatch or pixel duplication. Flag for audit.
- **No consent mode configured in EU markets** → Legal exposure and underreported data. Flag immediately.
- **All pages showing as "/(not set)" or generic paths** → SPA routing not handled. GA4 is recording wrong pages.
- **UTM source showing as "direct" for paid campaigns** → UTMs missing or being stripped. Traffic attribution is broken.

---

## Output Artifacts

| When you ask for... | You get... |
|--------------------|-----------|
| "Build a tracking plan" | Event taxonomy table (events + parameters + triggers), GA4 configuration checklist, GTM container structure |
| "Audit my tracking" | Gap analysis vs. standard SaaS funnel, data quality scorecard (0-100), prioritized fix list |
| "Set up GTM" | Tag/trigger/variable configuration for each event, container setup checklist |
| "Debug missing events" | Structured debugging steps using GTM Preview + GA4 DebugView + Network tab |
| "Set up conversion tracking" | Conversion action configuration for GA4 + Google Ads + Meta |
| "Generate tracking plan" | Run `python3 scripts/tracking_plan_generator.py [plan.json] [--json]` — event taxonomy + GA4/GTM checklist |

---

## Communication

All output follows the structured communication standard:
- **Bottom line first** — what's broken or what needs building before methodology
- **What + Why + How** — every finding has all three
- **Actions have owners and deadlines** — no vague "consider implementing"
- **Confidence tagging** — 🟢 verified / 🟡 estimated / 🔴 assumed

---

## Related Skills

- **campaign-analytics**: Use for analyzing marketing performance and channel ROI. NOT for implementation — use this skill for tracking setup.
- **ab-test-setup**: Use when designing experiments. NOT for event tracking setup (though this skill's events feed A/B tests).
- **analytics-tracking** (this skill): covers setup only. For dashboards and reporting, use campaign-analytics.
- **seo-audit**: Use for technical SEO. NOT for analytics tracking (though both use GA4 data).
- **gdpr-dsgvo-expert**: Use for GDPR compliance posture. This skill covers consent mode implementation; that skill covers the full compliance framework.

所有檔案

0 個檔案

安裝 analytics-tracking

請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/alirezarezvani/claude-skills/tree/main/marketing-skill/skills/analytics-tracking # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/ Claude 會自動偵測並使用該技能

相關技能

multica-creating-agents
更新時間 2026-08-12
tilemaps
更新時間 2026-08-04
v4-new-features
更新時間 2026-08-04
agent-github-pr-manager
更新時間 2026-08-03
OR