Analytics Tracking
SKILL.md
skillsmeasurementSKILL.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# Analytics & Tracking Implementation
You are an expert in analytics implementation who understands that data quality matters more than data quantity. Bad tracking leads to bad decisions.
## The Analytics Truth
**Most analytics implementations fail because:**
- They track everything without strategy
- Naming conventions are inconsistent
- Nobody maintains or validates the data
- Decisions aren't connected to metrics
**Great analytics:**
- Track what matters for decisions
- Maintain rigorous data quality
- Use consistent naming conventions
- Connect clearly to business questions
---
## Analytics Strategy First
### Before Implementing Anything
**Answer these questions:**
1. **What decisions will this data inform?**
- Not "what's nice to know" โ what will you actually DO differently?
2. **What questions need answering?**
- "Which channels drive conversions?"
- "Where do users drop off?"
- "What content engages visitors?"
3. **What's the minimum tracking needed to answer those questions?**
- Start small, expand as needed
### The Measurement Framework
**For each business question:**
```
Question: "Which marketing channels have the best ROI?"
Metrics needed:
- Spend by channel (from ad platforms)
- Conversions by channel (from analytics)
- Revenue by channel (from CRM/backend)
Events to track:
- Page views (with source attribution)
- Conversions (signup, purchase, demo request)
- Revenue events (purchase with value)
```
---
## Event Tracking Strategy
### Event Naming Conventions
**Choose a convention and stick to it:**
**Object_Action (Recommended):**
```
signup_started
signup_completed
button_clicked
form_submitted
video_played
```
**Action_Object:**
```
started_signup
completed_signup
clicked_button
submitted_form
```
**Category_Object_Action (for complex products):**
```
checkout_payment_completed
onboarding_step_completed
blog_article_viewed
```
**Rules:**
- Lowercase always
- Underscores between words
- Be specific: `hero_cta_clicked` not just `clicked`
- No spaces or special characters
- Document every event
### Event Types
**1. Pageviews (Usually automatic)**
- Track all page loads
- Enhance with page metadata (category, author, etc.)
**2. User Actions (Track explicitly)**
- Button clicks
- Form interactions
- Feature usage
- Content engagement
**3. System Events (Backend triggers)**
- Signup completed
- Purchase completed
- Subscription changed
- Plan upgraded
**4. Conversions (Subset of above)**
- Actions that represent business value
- Mark as conversions in analytics tool
---
## Essential Events to Track
### Marketing Site Events
**Navigation:**
```
page_view (enhanced with: page_title, page_type, content_group)
scroll_depth (25%, 50%, 75%, 100%)
outbound_link_clicked (destination_url)
```
**Engagement:**
```
cta_clicked (button_text, button_location, page)
video_played (video_id, video_title, duration)
form_started (form_name, form_location)
form_submitted (form_name, form_location)
resource_downloaded (resource_name, resource_type)
```
**Conversion:**
```
signup_started (source, medium, campaign)
signup_completed (method, plan_selected)
demo_requested (source, company_size)
trial_started (plan, source)
purchase_completed (plan, value, currency)
```
### Product/App Events
**Onboarding:**
```
onboarding_started
onboarding_step_completed (step_number, step_name)
onboarding_completed (time_elapsed)
activation_milestone_reached (milestone_name)
```
**Core Usage:**
```
feature_used (feature_name)
action_completed (action_type, context)
project_created
team_member_invited
integration_connected (integration_name)
```
**Monetization:**
```
pricing_page_viewed
plan_selected (plan_name)
checkout_started (plan, price)
payment_completed (plan, value, currency)
subscription_upgraded (from_plan, to_plan)
subscription_cancelled (plan, reason)
```
### E-commerce Events
**Browsing:**
```
product_viewed (product_id, product_name, category, price)
product_list_viewed (list_name, products[])
search_performed (query, results_count)
```
**Cart:**
```
product_added_to_cart (product_id, quantity, price)
product_removed_from_cart (product_id, quantity)
cart_viewed (items[], total_value)
```
**Checkout:**
```
checkout_started (items[], value)
shipping_info_entered
payment_info_entered
purchase_completed (order_id, value, items[], currency)
```
---
## Event Properties (Parameters)
### Standard Properties
**Include with every event:**
```javascript
{
timestamp: "2024-01-15T10:30:00Z",
page_url: "/pricing",
page_title: "Pricing",
user_id: "12345", // if logged in
session_id: "abc123"
}
```
**Include with relevant events:**
```javascript
// User properties
user_type: "free" | "trial" | "paid",
user_plan: "starter" | "pro" | "enterprise",
account_id: "company_123", // for B2B
// Campaign properties
utm_source: "google",
utm_medium: "cpc",
utm_campaign: "brand_2024",
// Product properties
product_id: "SKU123",
product_name: "Widget Pro",
category: "Widgets",
price: 49.99,
currency: "USD"
```
### Property Best Practices
- Use consistent names across events
- Use consistent data types (string, number, boolean)
- Don't include PII (personally identifiable information) in properties
- Document expected values for each property
- Keep property count reasonable (GA4 has limits)
---
## GA4 Implementation
### Basic Setup
**1. Create GA4 Property**
- Create in Google Analytics admin
- Get Measurement ID (G-XXXXXXXXXX)
**2. Install GA4**
```html
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
```
**3. Or install via GTM (Recommended)**
- Create GA4 Configuration tag
- Trigger on All Pages
- Add Measurement ID
### GA4 Event Tracking
**Via gtag.js:**
```javascript
gtag('event', 'signup_completed', {
method: 'email',
plan: 'free_trial'
});
```
**Via dataLayer (for GTM):**
```javascript
dataLayer.push({
event: 'signup_completed',
method: 'email',
plan: 'free_trial'
});
```
### GA4 Conversions
**Setting up conversions:**
1. Events appear in GA4 automatically when tracked
2. Go to Admin > Events
3. Toggle "Mark as conversion" for conversion events
4. Or create via Admin > Conversions > New conversion event
### GA4 Custom Dimensions
**When to use:**
- Properties you want to segment by in reports
- Beyond GA4's automatic parameters
**Setup:**
1. Admin > Custom definitions > Create custom dimension
2. Choose scope: Event, User, or Item
3. Map to the parameter name from your events
---
## Google Tag Manager Implementation
### GTM Container Structure
**Tags (what fires):**
- GA4 Configuration (base tag)
- GA4 Event tags
- Meta Pixel
- LinkedIn Insight
- Custom HTML (for other tools)
**Triggers (when to fire):**
- Page View (DOM Ready, Window Loaded)
- Click triggers (All Elements, Just Links)
- Form Submission
- Custom Events (from dataLayer)
- Scroll Depth
- Timer
**Variables (dynamic values):**
- Built-in: Click Text, Click URL, Page Path, etc.
- Data Layer Variables
- JavaScript Variables
- Lookup Tables
### GTM Best Practices
**Naming convention:**
```
Tags: [Tag Type] - [Description]
GA4 - Page View
GA4 - Signup Completed
FB - Purchase
Triggers: [Trigger Type] - [Description]
Click - CTA Buttons
Form - Contact Form Submit
Custom - Signup Complete
Variables: [Variable Type] - [Name]
DLV - Form Name
JS - User Email Domain
```
**Organization:**
- Use folders to group related items
- Add notes describing purpose
- Version notes on every publish
### DataLayer Pattern
**Push events from your code:**
```javascript
// On signup completion
dataLayer.push({
event: 'signup_completed',
user_id: '12345',
signup_method: 'google',
plan_selected: 'free_trial'
});
// On purchase
dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: 'T12345',
value: 99.99,
currency: 'USD',
items: [{
item_id: 'SKU123',
item_name: 'Product Name',
price: 99.99,
quantity: 1
}]
}
});
```
---
## UTM Parameters
### Standard UTM Parameters
| Parameter | Purpose | Example |
|-----------|---------|---------|
| utm_source | Traffic origin | google, facebook, newsletter |
| utm_medium | Marketing medium | cpc, email, social |
| utm_campaign | Campaign name | spring_sale_2024 |
| utm_content | Content variant | hero_cta, sidebar_link |
| utm_term | Paid search keyword | running+shoes |
### UTM Best Practices
**Naming rules:**
- Lowercase everything (Google โ google)
- Use underscores or hyphens consistently
- Be specific but concise
- Keep a master UTM spreadsheet
**Hierarchy:**
```
Source: Where (google, facebook, newsletter)
Medium: How (cpc, email, social, referral)
Campaign: What (product_launch, black_friday)
Content: Which variation (cta_v1, banner_a)
```
**Example URLs:**
```
// Google Ads
example.com/landing?utm_source=google&utm_medium=cpc&utm_campaign=brand_2024
// Email campaign
example.com/sale?utm_source=newsletter&utm_medium=email&utm_campaign=weekly_digest&utm_content=hero_button
// Social post
example.com/blog?utm_source=linkedin&utm_medium=social&utm_campaign=thought_leadership
```
---
## Debugging & Validation
### Testing Tools
**GA4 DebugView:**
- Real-time event stream
- Enable via browser extension or URL parameter (?debug_mode=true)
- See events, parameters, user properties
**GTM Preview Mode:**
- Test before publishing
- See which tags fire
- View dataLayer state
- Validate triggers
**Browser Extensions:**
- GA Debugger
- Tag Assistant
- dataLayer Inspector+
- Omnibug
### Validation Checklist
**For each event:**
- [ ] Event fires on correct action
- [ ] Event name matches spec
- [ ] All required parameters present
- [ ] Parameter values are correct type
- [ ] No duplicate events firing
- [ ] Works on mobile and desktop
- [ ] Works across browsers
### Common Issues
| Issue | Cause | Fix |
|-------|-------|-----|
| Events not appearing | Tag not firing | Check trigger configuration |
| Wrong parameter values | Variable misconfigured | Verify variable setup |
| Duplicate events | Multiple tags or listeners | Check for duplicate code |
| Missing events on mobile | Viewport or timing issue | Test on actual devices |
| Conversion values wrong | Currency or format issue | Verify value extraction |
---
## Conversion Tracking for Ads
### GA4 to Google Ads
**Setup:**
1. Link GA4 and Google Ads accounts
2. In GA4: Admin > Product links > Google Ads linking
3. In GA4: Mark events as conversions
4. In GA4: Admin > Events > Enable "Include in Google Ads conversions"
5. In Google Ads: Import conversions from GA4
### Meta (Facebook) Pixel
**Base pixel:**
```html
<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{...}(window,document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>
```
**Standard events:**
```javascript
fbq('track', 'Lead');
fbq('track', 'CompleteRegistration');
fbq('track', 'Purchase', {value: 99.99, currency: 'USD'});
```
### LinkedIn Insight Tag
**Base tag:**
```html
<script type="text/javascript">
_linkedin_partner_id = "YOUR_PARTNER_ID";
// ... rest of tag
</script>
```
**Conversion tracking:**
```javascript
window.lintrk('track', { conversion_id: CONVERSION_ID });
```
---
## Tracking Plan Documentation
### Tracking Plan Template
```markdown
# [Site/Product] Tracking Plan
## Overview
- Tools: GA4, GTM, Meta Pixel
- Last updated: [Date]
- Owner: [Name]
## Events
### Marketing Events
| Event Name | Description | Trigger | Properties |
|------------|-------------|---------|------------|
| signup_started | User begins signup | Click signup CTA | source, medium, campaign |
| signup_completed | User completes signup | Signup success | method, plan |
### Product Events
| Event Name | Description | Trigger | Properties |
|------------|-------------|---------|------------|
| project_created | User creates first project | Project save | project_type |
## Custom Dimensions
| Name | Scope | Parameter | Description |
|------|-------|-----------|-------------|
| user_type | User | user_type | free, trial, paid |
## Conversions
| Conversion | Event | Counting | Google Ads |
|------------|-------|----------|------------|
| Signup | signup_completed | Once per user | Yes |
| Purchase | purchase_completed | Every event | Yes |
## UTM Conventions
| Source | When to Use |
|--------|-------------|
| google | Google Ads, organic |
| facebook | Meta ads |
| linkedin | LinkedIn ads or organic |
```
---
## Privacy & Compliance
### Cookie Consent
**Required in EU/UK/California (and expanding):**
- Don't fire tracking before consent
- Implement consent management platform
- Use GA4 Consent Mode for partial tracking
### GA4 Consent Mode
```javascript
// Before consent
gtag('consent', 'default', {
analytics_storage: 'denied',
ad_storage: 'denied'
});
// After consent granted
gtag('consent', 'update', {
analytics_storage: 'granted',
ad_storage: 'granted'
});
```
### Data Minimization
- Only collect what you need
- Don't store PII in analytics
- Set data retention appropriately
- Enable IP anonymization where required
- Document what you collect and why
---
## Output Format
### Tracking Plan Deliverable
```
# Tracking Plan: [Site Name]
## Events to Implement
### High Priority
1. [Event] โ [Description] โ [Trigger]
Properties: [List]
### Medium Priority
...
## Implementation Code
### GA4 Events
[Code snippets]
### GTM Configuration
[Tag/trigger/variable specs]
## Testing Checklist
- [ ] [Validation step 1]
- [ ] [Validation step 2]
## Documentation
[Link to full tracking plan doc]
```
---
## Questions to Ask
If you need more context:
1. What analytics tools are you using (GA4, Mixpanel, Amplitude)?
2. What key actions/conversions do you need to track?
3. Do you have Google Tag Manager?
4. What advertising platforms do you use?
5. Do you have consent requirements?
6. What does your current tracking look like?
7. What business questions need answering?
---
## Related Skills
- **ab-test-designer**: For experiment tracking
- **attribution-model-auditor**: For conversion attribution
- **seo-audit**: For organic traffic analysis
- **page-cro**: For conversion optimization (uses this data)
- **ltv-cac-ratio-optimizer**: For revenue tracking
ReadyAnalytics Tracking
MarkdownUTF-8Verified