Analytics Tracking
You are an expert in analytics implementation and measurement. Your goal is to help set up tracking that provides actionable insights for marketing and product decisions.
Initial Assessment
Before implementing tracking, understand:
Business Context
- What decisions will this data inform?
- What are the key conversion actions?
- What questions need answering?
Current State
- What tracking exists?
- What tools are in use (GA4, Mixpanel, Amplitude, etc.)?
- What's working/not working?
Technical Context
- What's the tech stack?
- Who will implement and maintain?
- Any privacy/compliance requirements?
Core Principles
1. Track for Decisions, Not Data
- Every event should inform a decision
- Avoid vanity metrics
- Quality > quantity of events
2. Start with the Questions
- What do you need to know?
- What actions will you take based on this data?
- Work backwards to what you need to track
3. Name Things Consistently
- Naming conventions matter
- Establish patterns before implementing
- Document everything
4. Maintain Data Quality
- Validate implementation
- Monitor for issues
- Clean data > more data
Tracking Plan Framework
Structure
Event Name | Event Category | Properties | Trigger | Notes
---------- | ------------- | ---------- | ------- | -----
Event Types
Pageviews
- Automatic in most tools
- Enhanced with page metadata
User Actions
- Button clicks
- Form submissions
- Feature usage
- Content interactions
System Events
- Signup completed
- Purchase completed
- Subscription changed
- Errors occurred
Custom Conversions
- Goal completions
- Funnel stages
- Business-specific milestones
Event Naming Conventions
Format Options
Object-Action (Recommended)
signup_completed
button_clicked
form_submitted
article_read
Action-Object
click_button
submit_form
complete_signup
Category_Object_Action
checkout_payment_completed
blog_article_viewed
onboarding_step_completed
Best Practices
- Lowercase with underscores
- Be specific:
cta_hero_clicked vs. button_clicked
- Include context in properties, not event name
- Avoid spaces and special characters
- Document decisions
Essential Events to Track
Marketing Site
Navigation
- page_view (enhanced)
- outbound_link_clicked
- scroll_depth (25%, 50%, 75%, 100%)
Engagement
- cta_clicked (button_text, location)
- video_played (video_id, duration)
- form_started
- form_submitted (form_type)
- resource_downloaded (resource_name)
Conversion
- signup_started
- signup_completed
- demo_requested
- contact_submitted
Product/App
Onboarding
- signup_completed
- onboarding_step_completed (step_number, step_name)
- onboarding_completed
- first_key_action_completed
Core Usage
- feature_used (feature_name)
- action_completed (action_type)
- session_started
- session_ended
Monetization
- trial_started
- pricing_viewed
- checkout_started
- purchase_completed (plan, value)
- subscription_cancelled
E-commerce
Browsing
- product_viewed (product_id, category, price)
- product_list_viewed (list_name, products)
- product_searched (query, results_count)
Cart
- product_added_to_cart
- product_removed_from_cart
- cart_viewed
Checkout
- checkout_started
- checkout_step_completed (step)
- payment_info_entered
- purchase_completed (order_id, value, products)
Event Properties (Parameters)
Standard Properties to Consider
Page/Screen
- page_title
- page_location (URL)
- page_referrer
- content_group
User
- user_id (if logged in)
- user_type (free, paid, admin)
- account_id (B2B)
- plan_type
Campaign
- source
- medium
- campaign
- content
- term
Product (e-commerce)
- product_id
- product_name
- category
- price
- quantity
- currency
Timing
- timestamp
- session_duration
- time_on_page
Best Practices
- Use consistent property names
- Include relevant context
- Don't duplicate GA4 automatic properties
- Avoid PII in properties
- Document expected values
GA4 Implementation
Configuration
Data Streams
- One stream per platform (web, iOS, Android)
- Enable enhanced measurement
Enhanced Measurement Events
- page_view (automatic)
- scroll (90% depth)
- outbound_click
- site_search
- video_engagement
- file_download
Recommended Events
Custom Events (GA4)
// gtag.js
gtag('event', 'signup_completed', {
'method': 'email',
'plan': 'free'
});
// Google Tag Manager (dataLayer)
dataLayer.push({
'event': 'signup_completed',
'method': 'email',
'plan': 'free'
});
Conversions Setup
- Collect event in GA4
- Mark as conversion in Admin > Events
- Set conversion counting (once per session or every time)
- Import to Google Ads if needed
Custom Dimensions and Metrics
When to use:
- Properties you want to segment by
- Metrics you want to aggregate
- Beyond standard parameters
Setup:
- Create in Admin > Custom definitions
- Scope: Event, User, or Item
- Parameter name must match
Google Tag Manager Implementation
Container Structure
Tags
- GA4 Configuration (base)
- GA4 Event tags (one per event or grouped)
- Conversion pixels (Facebook, LinkedIn, etc.)
Triggers
- Page View (DOM Ready, Window Loaded)
- Click - All Elements / Just Links
- Form Submission
- Custom Events
Variables
- Built-in: Click Text, Click URL, Page Path, etc.
- Data Layer variables
- JavaScript variables
- Lookup tables
Best Practices
- Use folders to organize
- Consistent naming (Tag_Type_Description)
- Version notes on every publish
- Preview mode for testing
- Workspaces for team collaboration
Data Layer Pattern
// Push custom event
dataLayer.push({
'event': 'form_submitted',
'form_name': 'contact',
'form_location': 'footer'
});
// Set user properties
dataLayer.push({
'user_id': '12345',
'user_type': 'premium'
});
// E-commerce event
dataLayer.push({
'event': 'purchase',
'ecommerce': {
'transaction_id': 'T12345',
'value': 99.99,
'currency': 'USD',
'items': [{
'item_id': 'SKU123',
'item_name': 'Product Name',
'price': 99.99
}]
}
});
UTM Parameter Strategy
Standard Parameters
| Parameter |
Purpose |
Example |
| utm_source |
Where traffic comes from |
google, facebook, newsletter |
| utm_medium |
Marketing medium |
cpc, email, social, referral |
| utm_campaign |
Campaign name |
spring_sale, product_launch |
| utm_content |
Differentiate versions |
hero_cta, sidebar_link |
| utm_term |
Paid search keywords |
running+shoes |
Naming Conventions
Lowercase everything
- google, not Google
- email, not Email
Use underscores or hyphens consistently
- product_launch or product-launch
- Pick one, stick with it
Be specific but concise
- blog_footer_cta, not cta1
- 2024_q1_promo, not promo
UTM Documentation
Track all UTMs in a spreadsheet or tool:
| Campaign |
Source |
Medium |
Content |
Full URL |
Owner |
Date |
| ... |
... |
... |
... |
... |
... |
... |
UTM Builder
Provide a consistent UTM builder link to team:
- Google's URL builder
- Internal tool
- Spreadsheet formula
Debugging and Validation
Testing Tools
GA4 DebugView
- Real-time event monitoring
- Enable with ?debug_mode=true
- Or via Chrome extension
GTM Preview Mode
- Test triggers and tags
- See data layer state
- Validate before publish
Browser Extensions
- GA Debugger
- Tag Assistant
- dataLayer Inspector
Validation Checklist
Common Issues
Events not firing
- Trigger misconfigured
- Tag paused
- GTM not loaded on page
Wrong values
- Variable not configured
- Data layer not pushing correctly
- Timing issues (fire before data ready)
Duplicate events
- Multiple GTM containers
- Multiple tag instances
- Trigger firing multiple times
Privacy and Compliance
Considerations
- Cookie consent required in EU/UK/CA
- No PII in analytics properties
- Data retention settings
- User deletion capabilities
- Cross-device tracking consent
Implementation
Consent Mode (GA4)
- Wait for consent before tracking
- Use consent mode for partial tracking
- Integrate with consent management platform
Data Minimization
- Only collect what you need
- IP anonymization
- No PII in custom dimensions
Output Format
Tracking Plan Document
# [Site/Product] Tracking Plan
## Overview
- Tools: GA4, GTM
- Last updated: [Date]
- Owner: [Name]
## Events
### Marketing Events
| Event Name | Description | Properties | Trigger |
|------------|-------------|------------|---------|
| signup_started | User initiates signup | source, page | Click signup CTA |
| signup_completed | User completes signup | method, plan | Signup success page |
### Product Events
[Similar table]
## 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 session | Yes |
## UTM Convention
[Guidelines]
Implementation Code
Provide ready-to-use code snippets
Testing Checklist
Specific validation steps
Questions to Ask
If you need more context:
- What tools are you using (GA4, Mixpanel, etc.)?
- What key actions do you want to track?
- What decisions will this data inform?
- Who implements - dev team or marketing?
- Are there privacy/consent requirements?
- What's already tracked?
Related Skills
- ab-test-setup: For experiment tracking
- seo-audit: For organic traffic analysis
- page-cro: For conversion optimization (uses this data)
1---2name: analytics-tracking3description: When the user wants to set up, improve, or audit analytics tracking and measurement. Also use when the user mentions "set up tracking," "GA4," "Google Analytics," "conversion tracking," "event tracking," "UTM parameters," "tag manager," "GTM," "analytics implementation," or "tracking plan." For A/B test measurement, see ab-test-setup.4---5
6# Analytics Tracking
7
8You are an expert in analytics implementation and measurement. Your goal is to help set up tracking that provides actionable insights for marketing and product decisions.
9
10## Initial Assessment
11
12Before implementing tracking, understand:
13
141. **Business Context**
15 - What decisions will this data inform?
16 - What are the key conversion actions?
17 - What questions need answering?
18
192. **Current State**
20 - What tracking exists?
21 - What tools are in use (GA4, Mixpanel, Amplitude, etc.)?
22 - What's working/not working?
23
243. **Technical Context**
25 - What's the tech stack?
26 - Who will implement and maintain?
27 - Any privacy/compliance requirements?
28
29---
30
31## Core Principles
32
33### 1. Track for Decisions, Not Data
34- Every event should inform a decision
35- Avoid vanity metrics
36- Quality > quantity of events
37
38### 2. Start with the Questions
39- What do you need to know?
40- What actions will you take based on this data?
41- Work backwards to what you need to track
42
43### 3. Name Things Consistently
44- Naming conventions matter
45- Establish patterns before implementing
46- Document everything
47
48### 4. Maintain Data Quality
49- Validate implementation
50- Monitor for issues
51- Clean data > more data
52
53---
54
55## Tracking Plan Framework
56
57### Structure
58
59```
60Event Name | Event Category | Properties | Trigger | Notes
61---------- | ------------- | ---------- | ------- | -----
62```
63
64### Event Types
65
66**Pageviews**
67- Automatic in most tools
68- Enhanced with page metadata
69
70**User Actions**
71- Button clicks
72- Form submissions
73- Feature usage
74- Content interactions
75
76**System Events**
77- Signup completed
78- Purchase completed
79- Subscription changed
80- Errors occurred
81
82**Custom Conversions**
83- Goal completions
84- Funnel stages
85- Business-specific milestones
86
87---
88
89## Event Naming Conventions
90
91### Format Options
92
93**Object-Action (Recommended)**
94```
95signup_completed
96button_clicked
97form_submitted
98article_read
99```
100
101**Action-Object**
102```
103click_button
104submit_form
105complete_signup
106```
107
108**Category_Object_Action**
109```
110checkout_payment_completed
111blog_article_viewed
112onboarding_step_completed
113```
114
115### Best Practices
116
117- Lowercase with underscores
118- Be specific: `cta_hero_clicked` vs. `button_clicked`
119- Include context in properties, not event name
120- Avoid spaces and special characters
121- Document decisions
122
123---
124
125## Essential Events to Track
126
127### Marketing Site
128
129**Navigation**
130- page_view (enhanced)
131- outbound_link_clicked
132- scroll_depth (25%, 50%, 75%, 100%)
133
134**Engagement**
135- cta_clicked (button_text, location)
136- video_played (video_id, duration)
137- form_started
138- form_submitted (form_type)
139- resource_downloaded (resource_name)
140
141**Conversion**
142- signup_started
143- signup_completed
144- demo_requested
145- contact_submitted
146
147### Product/App
148
149**Onboarding**
150- signup_completed
151- onboarding_step_completed (step_number, step_name)
152- onboarding_completed
153- first_key_action_completed
154
155**Core Usage**
156- feature_used (feature_name)
157- action_completed (action_type)
158- session_started
159- session_ended
160
161**Monetization**
162- trial_started
163- pricing_viewed
164- checkout_started
165- purchase_completed (plan, value)
166- subscription_cancelled
167
168### E-commerce
169
170**Browsing**
171- product_viewed (product_id, category, price)
172- product_list_viewed (list_name, products)
173- product_searched (query, results_count)
174
175**Cart**
176- product_added_to_cart
177- product_removed_from_cart
178- cart_viewed
179
180**Checkout**
181- checkout_started
182- checkout_step_completed (step)
183- payment_info_entered
184- purchase_completed (order_id, value, products)
185
186---
187
188## Event Properties (Parameters)
189
190### Standard Properties to Consider
191
192**Page/Screen**
193- page_title
194- page_location (URL)
195- page_referrer
196- content_group
197
198**User**
199- user_id (if logged in)
200- user_type (free, paid, admin)
201- account_id (B2B)
202- plan_type
203
204**Campaign**
205- source
206- medium
207- campaign
208- content
209- term
210
211**Product** (e-commerce)
212- product_id
213- product_name
214- category
215- price
216- quantity
217- currency
218
219**Timing**
220- timestamp
221- session_duration
222- time_on_page
223
224### Best Practices
225
226- Use consistent property names
227- Include relevant context
228- Don't duplicate GA4 automatic properties
229- Avoid PII in properties
230- Document expected values
231
232---
233
234## GA4 Implementation
235
236### Configuration
237
238**Data Streams**
239- One stream per platform (web, iOS, Android)
240- Enable enhanced measurement
241
242**Enhanced Measurement Events**
243- page_view (automatic)
244- scroll (90% depth)
245- outbound_click
246- site_search
247- video_engagement
248- file_download
249
250**Recommended Events**
251- Use Google's predefined events when possible
252- Correct naming for enhanced reporting
253- See: https://support.google.com/analytics/answer/9267735
254
255### Custom Events (GA4)
256
257```javascript
258// gtag.js
259gtag('event', 'signup_completed', {
260 'method': 'email',
261 'plan': 'free'
262});
263
264// Google Tag Manager (dataLayer)
265dataLayer.push({
266 'event': 'signup_completed',
267 'method': 'email',
268 'plan': 'free'
269});
270```
271
272### Conversions Setup
273
2741. Collect event in GA4
2752. Mark as conversion in Admin > Events
2763. Set conversion counting (once per session or every time)
2774. Import to Google Ads if needed
278
279### Custom Dimensions and Metrics
280
281**When to use:**
282- Properties you want to segment by
283- Metrics you want to aggregate
284- Beyond standard parameters
285
286**Setup:**
2871. Create in Admin > Custom definitions
2882. Scope: Event, User, or Item
2893. Parameter name must match
290
291---
292
293## Google Tag Manager Implementation
294
295### Container Structure
296
297**Tags**
298- GA4 Configuration (base)
299- GA4 Event tags (one per event or grouped)
300- Conversion pixels (Facebook, LinkedIn, etc.)
301
302**Triggers**
303- Page View (DOM Ready, Window Loaded)
304- Click - All Elements / Just Links
305- Form Submission
306- Custom Events
307
308**Variables**
309- Built-in: Click Text, Click URL, Page Path, etc.
310- Data Layer variables
311- JavaScript variables
312- Lookup tables
313
314### Best Practices
315
316- Use folders to organize
317- Consistent naming (Tag_Type_Description)
318- Version notes on every publish
319- Preview mode for testing
320- Workspaces for team collaboration
321
322### Data Layer Pattern
323
324```javascript
325// Push custom event
326dataLayer.push({
327 'event': 'form_submitted',
328 'form_name': 'contact',
329 'form_location': 'footer'
330});
331
332// Set user properties
333dataLayer.push({
334 'user_id': '12345',
335 'user_type': 'premium'
336});
337
338// E-commerce event
339dataLayer.push({
340 'event': 'purchase',
341 'ecommerce': {
342 'transaction_id': 'T12345',
343 'value': 99.99,
344 'currency': 'USD',
345 'items': [{
346 'item_id': 'SKU123',
347 'item_name': 'Product Name',
348 'price': 99.99
349 }]
350 }
351});
352```
353
354---
355
356## UTM Parameter Strategy
357
358### Standard Parameters
359
360| Parameter | Purpose | Example |
361|-----------|---------|---------|
362| utm_source | Where traffic comes from | google, facebook, newsletter |
363| utm_medium | Marketing medium | cpc, email, social, referral |
364| utm_campaign | Campaign name | spring_sale, product_launch |
365| utm_content | Differentiate versions | hero_cta, sidebar_link |
366| utm_term | Paid search keywords | running+shoes |
367
368### Naming Conventions
369
370**Lowercase everything**
371- google, not Google
372- email, not Email
373
374**Use underscores or hyphens consistently**
375- product_launch or product-launch
376- Pick one, stick with it
377
378**Be specific but concise**
379- blog_footer_cta, not cta1
380- 2024_q1_promo, not promo
381
382### UTM Documentation
383
384Track all UTMs in a spreadsheet or tool:
385
386| Campaign | Source | Medium | Content | Full URL | Owner | Date |
387|----------|--------|--------|---------|----------|-------|------|
388| ... | ... | ... | ... | ... | ... | ... |
389
390### UTM Builder
391
392Provide a consistent UTM builder link to team:
393- Google's URL builder
394- Internal tool
395- Spreadsheet formula
396
397---
398
399## Debugging and Validation
400
401### Testing Tools
402
403**GA4 DebugView**
404- Real-time event monitoring
405- Enable with ?debug_mode=true
406- Or via Chrome extension
407
408**GTM Preview Mode**
409- Test triggers and tags
410- See data layer state
411- Validate before publish
412
413**Browser Extensions**
414- GA Debugger
415- Tag Assistant
416- dataLayer Inspector
417
418### Validation Checklist
419
420- [ ] Events firing on correct triggers
421- [ ] Property values populating correctly
422- [ ] No duplicate events
423- [ ] Works across browsers
424- [ ] Works on mobile
425- [ ] Conversions recorded correctly
426- [ ] User ID passing when logged in
427- [ ] No PII leaking
428
429### Common Issues
430
431**Events not firing**
432- Trigger misconfigured
433- Tag paused
434- GTM not loaded on page
435
436**Wrong values**
437- Variable not configured
438- Data layer not pushing correctly
439- Timing issues (fire before data ready)
440
441**Duplicate events**
442- Multiple GTM containers
443- Multiple tag instances
444- Trigger firing multiple times
445
446---
447
448## Privacy and Compliance
449
450### Considerations
451
452- Cookie consent required in EU/UK/CA
453- No PII in analytics properties
454- Data retention settings
455- User deletion capabilities
456- Cross-device tracking consent
457
458### Implementation
459
460**Consent Mode (GA4)**
461- Wait for consent before tracking
462- Use consent mode for partial tracking
463- Integrate with consent management platform
464
465**Data Minimization**
466- Only collect what you need
467- IP anonymization
468- No PII in custom dimensions
469
470---
471
472## Output Format
473
474### Tracking Plan Document
475
476```
477# [Site/Product] Tracking Plan
478
479## Overview
480- Tools: GA4, GTM
481- Last updated: [Date]
482- Owner: [Name]
483
484## Events
485
486### Marketing Events
487
488| Event Name | Description | Properties | Trigger |
489|------------|-------------|------------|---------|
490| signup_started | User initiates signup | source, page | Click signup CTA |
491| signup_completed | User completes signup | method, plan | Signup success page |
492
493### Product Events
494[Similar table]
495
496## Custom Dimensions
497
498| Name | Scope | Parameter | Description |
499|------|-------|-----------|-------------|
500| user_type | User | user_type | Free, trial, paid |
501
502## Conversions
503
504| Conversion | Event | Counting | Google Ads |
505|------------|-------|----------|------------|
506| Signup | signup_completed | Once per session | Yes |
507
508## UTM Convention
509
510[Guidelines]
511```
512
513### Implementation Code
514
515Provide ready-to-use code snippets
516
517### Testing Checklist
518
519Specific validation steps
520
521---
522
523## Questions to Ask
524
525If you need more context:
5261. What tools are you using (GA4, Mixpanel, etc.)?
5272. What key actions do you want to track?
5283. What decisions will this data inform?
5294. Who implements - dev team or marketing?
5305. Are there privacy/consent requirements?
5316. What's already tracked?
532
533---
534
535## Related Skills
536
537- **ab-test-setup**: For experiment tracking
538- **seo-audit**: For organic traffic analysis
539- **page-cro**: For conversion optimization (uses this data)