Analytics: Tracking
Guides analytics implementation: GA4 setup, event tracking, conversions, and data quality. Applies to web and app tracking across marketing channels.
When invoking: On first use, if helpful, open with 1-2 sentences on what this skill covers and why it matters, then provide the main output. On subsequent use or when the user asks to skip, go directly to the main output.
User ID
- Purpose: Cross-device, cross-session user identification
- Implementation: Set
user_id when user is identified (e.g., login); send to GA4
- Benefit: Accurate attribution across sessions; better audience building
CTA Attribution (Article ROI)
Track CTA clicks on key articles to measure content ROI:
| Action |
Purpose |
| Event per CTA |
e.g., cta_click with content_url, content_type |
| Conversion |
Mark as conversion in GA4 for attribution |
| Use |
Compare high vs low performers; optimize CTA placement and copy |
See seo-monitoring for article database and benchmark context.
Infrastructure Requirements
| Component |
Purpose |
| Data warehouse |
Centralized data; BI reporting |
| Event tracking |
User behavior; funnel mapping |
| Attribution |
Ad pixels; attribution model; impression-to-sale tracking |
Optimization flow: Clean UTM + conversion events → attribution reports → optimize channel mix.
Scope
- GA4: Web data stream, gtag.js, configuration
- User ID: Cross-device, cross-session identification
- CTA attribution: Per-article conversion tracking for content ROI
- Events: Recommended and custom events
- Conversions: Key events, parameters
- Quality: Naming, testing, validation
GA4 Setup
Prerequisites
- Google Analytics property and web data stream
- Google tag (gtag.js) on all pages
- Measurement ID (e.g.,
G-XXXXXXXXXX)
Enhanced Measurement
Enable in Admin > Data Streams > Enhanced Measurement for automatic tracking of:
- Page views, scrolls, outbound clicks
- Site search, file downloads
- Video engagement (YouTube)
Event Tracking
Event Types
| Type |
Description |
| Automatically collected |
page_view, first_visit, session_start |
| Enhanced measurement |
scroll, click, file_download, etc. |
| Recommended |
purchase, sign_up, search, etc. |
| Custom |
Business-specific actions |
Naming Conventions
- Length: <=40 characters (GA4 hard limit; longer names are not logged)
- Format:
snake_case, lowercase
- Verb first:
download_pdf, submit_form, video_play
- Context:
pricing_page_scroll vs generic scroll
gtag.js Syntax
gtag('event', '<event_name>', {
<parameter_name>: <value>,
// e.g. value: 99.99, currency: 'USD'
});
Place below the Google tag snippet. Events fire on page load or user action (e.g., button click).
Recommended Events
| Event |
Use |
Key Parameters |
purchase |
E-commerce |
value, currency, items |
sign_up |
Registration |
method |
login |
Login |
method |
search |
Site search |
search_term |
view_item |
Product view |
items |
add_to_cart |
Add to cart |
items |
Custom Events
- Focus on 15-25 meaningful events aligned with KPIs
- Add parameters for context (e.g.,
content_type, item_id)
- Avoid tracking everything; prioritize quality over quantity
Conversions (Key Events)
- Mark important events as conversions in GA4 Admin
- Use for attribution, audiences, and reporting
- Typical: purchase, sign_up, lead, contact
Attribution & Conversion Optimization
Attribution models determine how conversion credit is assigned across touchpoints. Use attribution data to optimize ads and growth channels.
| Model |
Use |
| Data-driven (GA4 default) |
ML assigns credit by actual contribution; best for multi-touch journeys |
| Last-click |
100% to final touchpoint; simple but undervalues awareness/consideration |
Optimization flow: Clean UTM (source, medium, campaign) + conversion events → GA4 attribution reports → compare channels by attributed conversions → reallocate budget to ads/channels that drive results. Inconsistent UTM fragments data; multi-touch attribution requires reliable touchpoint data.
Reference: UTM.io – UTMs for Marketing Attribution, GA4 – Get started with attribution
Testing & Validation
| Tool |
Use |
| Realtime |
See events as they fire |
| DebugView |
Detailed event/parameter inspection; requires debug mode |
| GA4 Debug mode |
gtag('config', 'G-XXX', { 'debug_mode': true }); or GTM preview |
- Test before launch; verify parameters and naming
- Check for duplicate events, missing values
Output Format
- Event list (name, trigger, parameters)
- Implementation notes (gtag or GTM)
- Conversion mapping
- Testing checklist
Related Skills
- traffic-analysis: UTM, source attribution; attribution for channel optimization
- ai-traffic-tracking: AI traffic in GA4
- google-search-console: GSC analysis (correlate with GA4)
- seo-monitoring: Article database, benchmark, full SEO monitoring framework
1---2name: analytics-tracking3description: When the user wants to set up, audit, or optimize analytics tracking (GA4, events, conversions). Also use when the user mentions "Google Analytics," "GA4," "event tracking," "conversions," "attribution model," "gtag," "data layer," "GA4 setup," "conversion tracking," "event setup," "User ID tracking," or "CTA attribution." For traffic insights, use traffic-analysis.4---5
6# Analytics: Tracking
7
8Guides analytics implementation: GA4 setup, event tracking, conversions, and data quality. Applies to web and app tracking across marketing channels.
9
10**When invoking**: On **first use**, if helpful, open with 1-2 sentences on what this skill covers and why it matters, then provide the main output. On **subsequent use** or when the user asks to skip, go directly to the main output.
11
12## User ID
13
14- **Purpose**: Cross-device, cross-session user identification
15- **Implementation**: Set `user_id` when user is identified (e.g., login); send to GA4
16- **Benefit**: Accurate attribution across sessions; better audience building
17
18## CTA Attribution (Article ROI)
19
20Track CTA clicks on key articles to measure content ROI:
21
22| Action | Purpose |
23|--------|---------|
24| **Event per CTA** | e.g., `cta_click` with `content_url`, `content_type` |
25| **Conversion** | Mark as conversion in GA4 for attribution |
26| **Use** | Compare high vs low performers; optimize CTA placement and copy |
27
28See **seo-monitoring** for article database and benchmark context.
29
30## Infrastructure Requirements
31
32| Component | Purpose |
33|-----------|---------|
34| **Data warehouse** | Centralized data; BI reporting |
35| **Event tracking** | User behavior; funnel mapping |
36| **Attribution** | Ad pixels; attribution model; impression-to-sale tracking |
37
38**Optimization flow**: Clean UTM + conversion events → attribution reports → optimize channel mix.
39
40## Scope
41
42- **GA4**: Web data stream, gtag.js, configuration
43- **User ID**: Cross-device, cross-session identification
44- **CTA attribution**: Per-article conversion tracking for content ROI
45- **Events**: Recommended and custom events
46- **Conversions**: Key events, parameters
47- **Quality**: Naming, testing, validation
48
49## GA4 Setup
50
51### Prerequisites
52
53- Google Analytics property and web data stream
54- Google tag (gtag.js) on all pages
55- Measurement ID (e.g., `G-XXXXXXXXXX`)
56
57### Enhanced Measurement
58
59Enable in Admin > Data Streams > Enhanced Measurement for automatic tracking of:
60
61- Page views, scrolls, outbound clicks
62- Site search, file downloads
63- Video engagement (YouTube)
64
65## Event Tracking
66
67### Event Types
68
69| Type | Description |
70|------|-------------|
71| **Automatically collected** | page_view, first_visit, session_start |
72| **Enhanced measurement** | scroll, click, file_download, etc. |
73| **Recommended** | purchase, sign_up, search, etc. |
74| **Custom** | Business-specific actions |
75
76### Naming Conventions
77
78- **Length**: <=40 characters (GA4 hard limit; longer names are not logged)
79- **Format**: `snake_case`, lowercase
80- **Verb first**: `download_pdf`, `submit_form`, `video_play`
81- **Context**: `pricing_page_scroll` vs generic `scroll`
82
83### gtag.js Syntax
84
85```javascript
86gtag('event', '<event_name>', {
87 <parameter_name>: <value>,
88 // e.g. value: 99.99, currency: 'USD'
89});
90```
91
92Place below the Google tag snippet. Events fire on page load or user action (e.g., button click).
93
94### Recommended Events
95
96| Event | Use | Key Parameters |
97|-------|-----|----------------|
98| `purchase` | E-commerce | value, currency, items |
99| `sign_up` | Registration | method |
100| `login` | Login | method |
101| `search` | Site search | search_term |
102| `view_item` | Product view | items |
103| `add_to_cart` | Add to cart | items |
104
105### Custom Events
106
107- Focus on 15-25 meaningful events aligned with KPIs
108- Add parameters for context (e.g., `content_type`, `item_id`)
109- Avoid tracking everything; prioritize quality over quantity
110
111## Conversions (Key Events)
112
113- Mark important events as conversions in GA4 Admin
114- Use for attribution, audiences, and reporting
115- Typical: purchase, sign_up, lead, contact
116
117## Attribution & Conversion Optimization
118
119Attribution models determine how conversion credit is assigned across touchpoints. Use attribution data to optimize ads and growth channels.
120
121| Model | Use |
122|-------|-----|
123| **Data-driven** (GA4 default) | ML assigns credit by actual contribution; best for multi-touch journeys |
124| **Last-click** | 100% to final touchpoint; simple but undervalues awareness/consideration |
125
126**Optimization flow**: Clean UTM (source, medium, campaign) + conversion events → GA4 attribution reports → compare channels by attributed conversions → reallocate budget to ads/channels that drive results. Inconsistent UTM fragments data; multi-touch attribution requires reliable touchpoint data.
127
128**Reference**: [UTM.io – UTMs for Marketing Attribution](https://web.utm.io/blog/utms-for-marketing-attribution/), [GA4 – Get started with attribution](https://support.google.com/analytics/answer/10596866)
129
130## Testing & Validation
131
132| Tool | Use |
133|------|-----|
134| **Realtime** | See events as they fire |
135| **DebugView** | Detailed event/parameter inspection; requires debug mode |
136| **GA4 Debug mode** | `gtag('config', 'G-XXX', { 'debug_mode': true });` or GTM preview |
137
138- Test before launch; verify parameters and naming
139- Check for duplicate events, missing values
140
141## Output Format
142
143- **Event list** (name, trigger, parameters)
144- **Implementation** notes (gtag or GTM)
145- **Conversion** mapping
146- **Testing** checklist
147
148## Related Skills
149
150- **traffic-analysis**: UTM, source attribution; attribution for channel optimization
151- **ai-traffic-tracking**: AI traffic in GA4
152- **google-search-console**: GSC analysis (correlate with GA4)
153- **seo-monitoring**: Article database, benchmark, full SEO monitoring framework