Skill — Analytics Instrumentation (Privacy-Aware Event Architecture)
When this skill activates
When designing event tracking systems, building data layers, creating tracking plans,
instrumenting user journeys, or establishing analytics governance. Use for any task
that involves measuring user behavior in a structured, privacy-respecting way.
Core principle: Track intent, not surveillance — measure what users DO to improve
what you BUILD, never to manipulate or over-collect.
Mandatory actions when this skill is active
Event Taxonomy Design
Naming convention (object_action format):
Format: [object]_[action]
Examples:
- button_clicked
- form_submitted
- page_viewed
- cart_item_added
- search_performed
- error_encountered
Rules:
- Always past tense for the action (clicked, not click)
- Lowercase with underscores (snake_case)
- Object first, action second (noun_verb)
- Maximum 3 words total (object can be compound: cart_item_added)
- Never include PII in event names
- Never include dynamic values in event names (no "product_12345_viewed")
Event property schema:
{
"event": "button_clicked",
"properties": {
"button_id": "string (required) — unique identifier",
"button_text": "string (required) — visible label",
"page_path": "string (required) — current URL path",
"section": "string (optional) — page section containing button",
"variant": "string (optional) — A/B test variant if applicable"
},
"context": {
"timestamp": "ISO-8601 (auto)",
"session_id": "string (auto)",
"device_type": "string (auto)",
"viewport_width": "number (auto)"
}
}
Rules:
- Separate event-specific properties from auto-collected context
- Mark each property as required or optional
- Include data type and brief description
- Never include PII in properties without explicit consent flag
Tracking Plan
Tracking plan structure (source of truth):
| Event Name | Trigger | Properties | Owner | Status |
|------------------|----------------------------|--------------------|----------|--------------|
| page_viewed | Page load complete | page_path, title | @fe-team | Implemented |
| button_clicked | Any tracked button click | button_id, text | @fe-team | In Review |
| form_submitted | Form submission success | form_id, fields | @fe-team | Planned |
Rules:
- Every event MUST have an owner (team or individual)
- Status lifecycle: Planned → In Review → Implemented → Validated → Deprecated
- Review tracking plan quarterly: deprecate unused events
- New events require tracking plan entry BEFORE implementation
Data Layer Architecture
Data layer implementation:
// Structured data layer (consumed by analytics tools)
window.dataLayer = window.dataLayer || [];
// Push events with standard structure
window.dataLayer.push({
event: 'button_clicked',
properties: {
button_id: 'cta-signup-hero',
button_text: 'Start Free Trial',
page_path: '/pricing'
}
});
Rules:
- Data layer is the SINGLE source of truth (analytics tools consume it, don't instrument directly)
- Never push to data layer before consent is granted
- Validate data layer pushes against schema in CI
- Data layer must be populated server-side for critical events (don't rely solely on client JS)
Privacy-Aware Analytics
Privacy requirements (non-negotiable):
- Obtain consent BEFORE any tracking fires (banner/modal with granular choices)
- Honor Do Not Track (DNT) header — respect user preference
- Anonymize by default: no full IP, no fingerprinting, no cross-site tracking
- Data retention: define maximum retention per event type (default 13 months for GDPR)
- Right to deletion: ensure analytics pipeline can purge by user ID
- Consent categories: necessary (no consent needed) | analytics (consent required) | marketing (separate consent)
Consent implementation:
// Only track if user has consented to analytics category
if (consentManager.hasConsent('analytics')) {
dataLayer.push({ event: 'page_viewed', properties: {...} });
}
Funnel Measurement
Funnel definition:
Funnel: [name]
Steps:
1. page_viewed (page_path = '/pricing') → Entry
2. button_clicked (button_id = 'select-plan') → Intent
3. form_submitted (form_id = 'payment') → Commitment
4. purchase_completed → Conversion
Metrics per step:
- Volume (count)
- Conversion rate (step N / step N-1)
- Drop-off rate (1 - conversion rate)
- Time between steps (median, p95)
Rules:
- Define funnels for every critical user journey
- Segment funnels by: device, acquisition source, user cohort, experiment variant
- Alert on significant drop-off changes (>10% deviation from baseline)
- Funnel steps must use the same event taxonomy
Analytics Governance
- Governance processes:
- Schema validation in CI: every new event must match the tracking plan schema
- Unused event cleanup: quarterly audit, deprecate events with <100 fires/month
- Naming review: new events require team lead approval (prevents drift)
- Data quality monitoring: alert on sudden volume spikes/drops (instrumentation bugs)
- Documentation: tracking plan is the living doc, not code comments
Self-check before task completion
Before marking a task done when this skill was active:
1---2name: analytics-instrumentation3description: Skill — Analytics Instrumentation (Privacy-Aware Event Architecture)4---56# Skill — Analytics Instrumentation (Privacy-Aware Event Architecture)78## When this skill activates9When designing event tracking systems, building data layers, creating tracking plans,10instrumenting user journeys, or establishing analytics governance. Use for any task11that involves measuring user behavior in a structured, privacy-respecting way.1213Core principle: **Track intent, not surveillance** — measure what users DO to improve14what you BUILD, never to manipulate or over-collect.1516## Mandatory actions when this skill is active1718### Event Taxonomy Design19201. **Naming convention (object_action format):**21 ```22 Format: [object]_[action]23 Examples:24 - button_clicked25 - form_submitted26 - page_viewed27 - cart_item_added28 - search_performed29 - error_encountered30 ```3132 Rules:33 - Always past tense for the action (clicked, not click)34 - Lowercase with underscores (snake_case)35 - Object first, action second (noun_verb)36 - Maximum 3 words total (object can be compound: cart_item_added)37 - Never include PII in event names38 - Never include dynamic values in event names (no "product_12345_viewed")39402. **Event property schema:**41 ```json42 {43 "event": "button_clicked",44 "properties": {45 "button_id": "string (required) — unique identifier",46 "button_text": "string (required) — visible label",47 "page_path": "string (required) — current URL path",48 "section": "string (optional) — page section containing button",49 "variant": "string (optional) — A/B test variant if applicable"50 },51 "context": {52 "timestamp": "ISO-8601 (auto)",53 "session_id": "string (auto)",54 "device_type": "string (auto)",55 "viewport_width": "number (auto)"56 }57 }58 ```5960 Rules:61 - Separate event-specific properties from auto-collected context62 - Mark each property as required or optional63 - Include data type and brief description64 - Never include PII in properties without explicit consent flag6566### Tracking Plan67683. **Tracking plan structure (source of truth):**69 ```70 | Event Name | Trigger | Properties | Owner | Status |71 |------------------|----------------------------|--------------------|----------|--------------|72 | page_viewed | Page load complete | page_path, title | @fe-team | Implemented |73 | button_clicked | Any tracked button click | button_id, text | @fe-team | In Review |74 | form_submitted | Form submission success | form_id, fields | @fe-team | Planned |75 ```7677 Rules:78 - Every event MUST have an owner (team or individual)79 - Status lifecycle: Planned → In Review → Implemented → Validated → Deprecated80 - Review tracking plan quarterly: deprecate unused events81 - New events require tracking plan entry BEFORE implementation8283### Data Layer Architecture84854. **Data layer implementation:**86 ```javascript87 // Structured data layer (consumed by analytics tools)88 window.dataLayer = window.dataLayer || [];8990 // Push events with standard structure91 window.dataLayer.push({92 event: 'button_clicked',93 properties: {94 button_id: 'cta-signup-hero',95 button_text: 'Start Free Trial',96 page_path: '/pricing'97 }98 });99 ```100101 Rules:102 - Data layer is the SINGLE source of truth (analytics tools consume it, don't instrument directly)103 - Never push to data layer before consent is granted104 - Validate data layer pushes against schema in CI105 - Data layer must be populated server-side for critical events (don't rely solely on client JS)106107### Privacy-Aware Analytics1081095. **Privacy requirements (non-negotiable):**110 - Obtain consent BEFORE any tracking fires (banner/modal with granular choices)111 - Honor Do Not Track (DNT) header — respect user preference112 - Anonymize by default: no full IP, no fingerprinting, no cross-site tracking113 - Data retention: define maximum retention per event type (default 13 months for GDPR)114 - Right to deletion: ensure analytics pipeline can purge by user ID115 - Consent categories: necessary (no consent needed) | analytics (consent required) | marketing (separate consent)1161176. **Consent implementation:**118 ```javascript119 // Only track if user has consented to analytics category120 if (consentManager.hasConsent('analytics')) {121 dataLayer.push({ event: 'page_viewed', properties: {...} });122 }123 ```124125### Funnel Measurement1261277. **Funnel definition:**128 ```129 Funnel: [name]130 Steps:131 1. page_viewed (page_path = '/pricing') → Entry132 2. button_clicked (button_id = 'select-plan') → Intent133 3. form_submitted (form_id = 'payment') → Commitment134 4. purchase_completed → Conversion135136 Metrics per step:137 - Volume (count)138 - Conversion rate (step N / step N-1)139 - Drop-off rate (1 - conversion rate)140 - Time between steps (median, p95)141 ```142143 Rules:144 - Define funnels for every critical user journey145 - Segment funnels by: device, acquisition source, user cohort, experiment variant146 - Alert on significant drop-off changes (>10% deviation from baseline)147 - Funnel steps must use the same event taxonomy148149### Analytics Governance1501518. **Governance processes:**152 - **Schema validation in CI**: every new event must match the tracking plan schema153 - **Unused event cleanup**: quarterly audit, deprecate events with <100 fires/month154 - **Naming review**: new events require team lead approval (prevents drift)155 - **Data quality monitoring**: alert on sudden volume spikes/drops (instrumentation bugs)156 - **Documentation**: tracking plan is the living doc, not code comments157158## Self-check before task completion159160Before marking a task done when this skill was active:161162- [ ] Did I follow the object_action naming convention?163- [ ] Is every event documented in the tracking plan with owner and status?164- [ ] Does the data layer implementation gate on user consent?165- [ ] Are PII fields excluded from event properties (or flagged for special handling)?166- [ ] Did I define funnels for critical user journeys with per-step metrics?167- [ ] Is there a governance process for event lifecycle management?168- [ ] Can the schema be validated in CI (preventing undocumented events)?169- [ ] Is data retention defined and compliant with privacy regulations?