analytics-sdk-setup
by @peter-wf
Use this skill whenever a user wants a coding agent to audit, install, reconcile, align, or fix TikTok Pixel and/or Meta Pixel code in a real repo — especial...
clawhub install analytics-sdk-setup📖 About This Skill
name: analytics-sdk-setup description: Use this skill whenever a user wants a coding agent to audit, install, reconcile, align, or fix TikTok Pixel and/or Meta Pixel code in a real repo — especially for duplicate init, tracking drift, event mapping, consent/CSP/LDU/privacy gating, or unclear analytics ownership.
Analytics SDK Setup
Use this skill when the user wants a coding agent to inspect, install, compare, align, reconcile, or fix TikTok Pixel and Meta Pixel tracking in a real codebase.
Activate it even when the user does not name this skill directly, as long as the real job is repo-level Pixel debugging or alignment work such as duplicate init, broken page-view behavior, tracking drift, event mapping, consent/CSP review, or source-of-truth cleanup.
This skill is for repo-aware coding agents such as Claude Code, Cursor, and similar tools. The agent must inspect the repo, find the shared bootstrap location, avoid duplicate initialization, preserve valid existing integrations, and make privacy/compliance decisions explicit before enabling sensitive tracking.
Companion prompt
If the environment does not load SKILL.md directly and instead expects a single prompt block, use:
agent-system-prompt.mdUse SKILL.md as the canonical skill specification and agent-system-prompt.md as the compact runtime summary.
Example usage
Use this skill for requests like:
Do not use this skill when the user only wants a conceptual explanation without repo analysis or implementation.
Core objective
This skill is not only about installing or fixing a single Pixel.
Its core objective is to help the agent manage TikTok and Meta as a dual-platform tracking system:
TikTok may appear first in examples or references, but the skill scope is not TikTok-only. Any implementation, audit, or repair should consider both platforms when they are in scope.
REQUIRED FIRST STEP
Before doing anything, you MUST:
1. classify execution mode (Mode A, Mode B, or Mode C)
2. output the chosen mode explicitly
3. justify the choice in 1-2 lines
DO NOT write any code before this step.
Quick fix mode
If the user request is clearly narrow, such as fixing duplicate initialization or adding one event:
Use quick-fix judgment only when the scope is genuinely narrow and privacy blockers are still resolved.
Quick fix mode does not bypass the output contract. Keep required sections for the chosen mode, but you may keep non-critical governance sections brief or mark them as not applicable.
Thinking steps (MUST follow)
1. What is the user asking? 2. Is the repo available? 3. Are blockers present? 4. Choose execution mode. 5. Then proceed.
When to activate
Activate when the user asks for any of the following:
This should still activate when the user never says "analytics-sdk-setup" but clearly needs repo-aware Pixel inspection, repair, or alignment.
When not to activate
Do not activate the full execution flow when the user is only asking for:
If the user only wants explanation, answer directly instead of running this full skill workflow.
Cross-platform decision frame
When TikTok and Meta are both in scope, always evaluate the work through these four lenses:
1. Per-platform correctness
- Is each platform installed correctly, initialized once, and emitting events at the right business moment?
2. Cross-platform consistency
- Do both platforms represent the same business action with compatible timing and core semantics?
3. Ownership and source of truth
- Which file, module, wrapper, provider, or tag manager owns bootstrap, event mapping, privacy gating, and parameter contracts?
4. Governance over local fixes
- Will a local repair improve the overall dual-platform system, or will it increase drift between TikTok and Meta?
When a local fix would make dual-platform governance worse, prefer a plan or governance recommendation over a narrow patch.
Execution mode decision
Before proposing code changes, choose exactly one execution mode.
Mode A: Direct implementation
Use direct implementation only when all of the following are true:
Mode B: Plan first
Use plan-first when the codebase is available but the work is still design-heavy, such as:
You MUST NOT modify code or propose patches in this mode.
Mode C: Questions first
Ask the minimum number of high-impact questions first when any blocker is present, including:
You MUST NOT propose implementation or code in this mode.
When in doubt, prefer: 1. audit over implementation, 2. plan over broad refactor, 3. preserving existing privacy behavior over enabling new tracking, 4. minimal bootstrap fixes over speculative event expansion.
Required inputs and blocking conditions
Collect or confirm these inputs before substantial changes.
Required for direct implementation
Blocking conditions
Do not directly implement sensitive or ambiguous behavior if any of the following is unresolved:
If a blocker exists, switch to plan-first or questions-first instead of guessing.
Safe defaults and conservative behavior
When information is incomplete, use these defaults:
Repo inspection workflow
Always inspect the existing code before adding or moving SDK code.
Follow this order:
1. Identify the target app, site, or package the user actually wants tracked.
2. Determine how pages are produced: shared HTML template, SSR layout, SPA shell, Next.js layout, or existing analytics provider.
3. Locate the best shared bootstrap location.
4. Search for existing TikTok and Meta initialization.
5. Search for existing event dispatch, helper wrappers, route-change hooks, and tag-manager bridges.
6. Identify ownership and source of truth for:
- bootstrap placement
- event taxonomy
- parameter contract
- consent or privacy gating
- tag-manager vs app-code boundaries
7. Classify the governance state as one of:
- single-platform only
- dual-platform but ungoverned
- platform-correct but cross-platform drifted
- aligned with intentional platform-specific differences
- privacy/governance blocked
8. Record engineering tags where relevant, such as:
- duplicate initialization
- event-only mismatch
- privacy / gating mismatch
- wrapper conflict
- CSP blocked
9. Choose the execution mode again if the repo evidence changes the initial judgment.
Duplicate detection protocol
Before changing anything, inspect both direct calls and wrapped integrations.
Search for direct init and page-view calls
ttq.load(ttq.page(fbq('init'fbq('track', 'PageView'Also inspect wrapper-level ownership
Check for:ttq or fbqTreat these as duplicate-risk scenarios
Consolidation rule
If duplicate initialization is found and ownership is clear: 1. Keep one initialization in the best shared location. 2. Remove the other init/load calls. 3. Preserve valid event tracking unless it is also incorrect. 4. Reuse or centralize existing config only when it reduces duplication without creating a broader refactor.If ownership is not clear, do not auto-merge competing integrations. Switch to plan-first or questions-first.
Implementation workflow
Use this workflow only in direct-implementation mode.
1. Keep or create exactly one shared bootstrap location per platform. 2. Prefer an existing global layout, base template, app shell, or analytics provider over scattered snippets. 3. Reuse existing config, environment flags, consent utilities, and privacy wrappers when available. 4. Fix duplicate initialization before expanding event code. 5. Define or preserve a shared business-event contract before mapping into TikTok and Meta specifics. 6. Add or normalize event calls only at the real business success point. 7. Align TikTok and Meta payloads only where the same business action is clearly intended on both platforms. 8. Keep changes minimal, localized, and related only to tracking. 9. Prefer fixing broken event calls over re-installing the SDK.
Do not:
For detailed bootstrap placement, event naming, mapping, payload examples, and verification guidance, consult references/install-and-events.md before implementing event-related changes.
Plan-only workflow
Use this workflow when the repo is available but implementation should not start yet.
Produce a concise implementation-ready report with:
Prefer a plan over direct edits when the main task is still architecture, scope selection, event design, or cross-platform governance.
Ownership and source of truth
When TikTok and Meta are both in scope, identify and report:
If ownership is split, the plan or implementation report should say whether that split is intentional, temporary, or the source of current drift.
Privacy and compliance guardrails
Before enabling sensitive behavior, explicitly inspect privacy constraints.
For CSP, consent gating, LDU, identifier handling, and shared privacy governance details, consult references/privacy-and-csp.md before implementing those changes.
Output contract
Use one of the following result structures.
If you are in questions-first mode
# Analytics SDK questionsWhat blocks implementation
... Decisions that affect both TikTok and Meta
... Required answers
1. ...
2. ...
3. ...Safe progress so far
...
Ask the minimum number of high-impact questions. Do not dump the full input checklist if only 2-3 answers are blocking progress.
If you are in plan-first mode
# Analytics SDK setup planWhat I confirmed
Platforms:
Framework / render path:
Intended environments:
Tracking scope:
Current state by platform:
Governance state: TikTok vs Meta gaps
... What to unify
... What remains platform-specific
... Ownership / source of truth
... Blockers or missing decisions
Pixel ID(s):
CSP status:
Consent gating:
LDU rule:
PII / Advanced Matching:
Event list: Governance recommendation
... Recommended next step
...
If you are in direct-implementation mode
# Analytics SDK implementationBootstrap location
file/path
why this is the shared render point Current state by platform
TikTok:
Meta: Cross-platform decisions
... What was unified
... Intentional platform-specific differences
... Ownership / source of truth
... Privacy / compliance decisions
CSP:
Consent gating:
LDU:
Advanced Matching: Event mapping implemented
business action -> TikTok event -> Meta event -> code location TikTok vs Meta gaps that remain
... Verification
per-platform correctness holds
cross-platform consistency is improved or explicitly bounded
bootstrap initializes once per platform
target events fire once at the correct business moment
privacy gates behave as intended
Reference routing
If the task involves:
references/install-and-events.mdreferences/privacy-and-csp.mdKeep vendor snippets, payload examples, and low-level policy details in references, not in this main skill file.
Pre-implementation gate
Before writing code, confirm all of the following:
If any item fails, do not proceed with broad implementation.
Post-implementation verification
Before finishing, verify two layers of success.
Per-platform correctness
currency and value when applicable.