GA4 Analytics Optimizer

Analytics tracking

by kostja94 · MIT license · ★ 1,006 on GitHub

Analytics tracking cover

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…

---
name: analytics-tracking
description: 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.
metadata:
  version: 1.3.1
---

# 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

Overview

Guides analytics implementation: GA4 setup, event tracking, conversions, and data quality. Applies to web and app tracking across marketing channels.

What you get

  • Event list(name, trigger, parameters)
  • Implementationnotes (gtag or GTM)
  • Conversionmapping
  • Testingchecklist
Manual install (npx, ZIP)
Claude Codenpx skills add kostja94/marketing-skills --skill analytics-tracking -g -a claude-code
Claude Code (degit)npx degit kostja94/marketing-skills/skills/analytics/tracking#main ~/.claude/skills/analytics-tracking-kostja94
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md5.7 KB
Read SKILL.md here
kostja94/main1 file shown
SKILL.md
Show the full text156 lines

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).

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

Details

License
MIT
Stars on the repo
★ 1,006
Checked
Source
kostja94/marketing-skills ↗
Creator
kostja94 · 106 listings
View creator

Similar skills

See all →
SkillAttribution AuditorAgriciDaniel/claude-ads · by AgriciDanielPaste the sales and spend numbers each ad platform claims, and get back a plain explanation of why they disagree and which figure to trust.★ 9.5k GitHub starsSkillFirst-Party Analytics SetupLeadMagic/gtm-skills · by LeadMagicSet up first-party tracking and analytics — website pixels, conversion tracking, UTM architecture, cookie consent, server-side tagging vs client-side, 1P vs 3P data strategy, and identity resolution. Use when setting up tracking, implementing pixels, building attribution, or preparing for privacy-first measurement. Triggers on: "pixel", "tracking", "conversion tracking", "first-party data", server-side tagging", "UTM", "cookie consent", "1P vs 3P", "identity resolution", or any tracking implementation request.★ 62 GitHub starsSkillWeb Analytics Setupcoreyhaines31/marketingskills · by coreyhaines31When 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," "tracking plan," "how do I measure this," "track conversions," "Mixpanel," "Segment," "are my events firing," or "analytics isn't working." Use this whenever someone asks how to know if something is working or wants to measure marketing results. For choosing attribution models, comparing multi-touch/MMM/incrementality, or reconciling conflicting numbers across tools, see attribution. For A/B test measurement, see ab-testing.★ 51.1k GitHub starsSkillSales Channel Attributioncoreyhaines31/marketingskills · by coreyhaines31Paste the conflicting numbers from your ad accounts, website stats and sales records; get back one honest read on which channels really drove sales and where to put your budget.★ 51.1k GitHub starsSkillAnalytics Tracking Setupdavila7/claude-code-templates · by davila7When 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.★ 32.3k GitHub starsAgentMarketing Attribution Analystdavila7/claude-code-templates · by davila7Use when you need to model multi-touch attribution, measure marketing mix impact, validate channel performance with incrementality testing, or optimize budget allocation across paid/owned/earned channels. Specifically:\\n\\n<example>\\nContext: A DTC brand spends across paid search, paid social, and email but can't tell which channels are actually driving incremental revenue versus just claiming credit for conversions that would have happened anyway.\\nuser: "Our last-click attribution says paid social drives 40% of revenue, but we're not sure that's real. How do we find out?"\\nassistant: "I'll first confirm your tracking stack (GA4/GTM/CDP), attribution window, and available spend/conversion data. Then I'll build a multi-touch attribution query alongside a geo-based incrementality test to validate whether paid social's credited revenue reflects true incremental lift or is displacing organic/brand-search conversions. I'll triangulate the MTA output against the incrementality result before recommending any budget shift."\\n<commentary>\\nUse marketing-attribution-analyst when the question is specifically about cross-channel credit assignment and causal validation of marketing spend. This differs from content-marketer (which measures content-specific engagement/ROI for a single content program) and market-researcher (external market sizing/customer research) — this agent works with the company's own tracking and spend data to answer "which channel/touchpoint gets credit, and is that credit real."\\n</commentary>\\n</example>\\n\\n<example>\\nContext: A mid-market SaaS company with $2M/year in marketing spend wants to move from last-click attribution to something more defensible before their next board budget review.\\nuser: "We need a real methodology to justify our channel budget split to the board next quarter. What should we actually use?"\\nassistant: "Given your spend level, I'll recommend a triangulated approach: a lightweight Bayesian MMM (e.g., Google Meridian) for strategic quarterly allocation, incrementality/holdout tests on your top 2-3 channels for causal validation, and multi-touch attribution for tactical, campaign-level optimization in between. I'll ask for your historical spend/conversion data and current tracking setup before building anything."\\n<commentary>\\nUse marketing-attribution-analyst for measurement-strategy decisions (which methodology fits the business's spend level and data maturity), not just for running one specific model. It differs from business-analyst, which focuses on broader operational/process data rather than marketing-channel causal measurement.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: A retailer's GA4 attribution numbers shifted significantly after a tracking migration and marketing wants to know if the channel mix actually changed or if it's a measurement artifact.\\nuser: "Our GA4 numbers look totally different since we migrated our tagging setup last month. Did our channel mix actually shift, or is this a tracking issue?"\\nassistant: "I'll ask what changed in the migration (consent mode configuration, server-side tagging, conversion API setup) and pull the pre/post data. I'll check for signal-loss patterns consistent with consent or tagging gaps versus a genuine behavioral shift, and validate any real shift with an incrementality read before you act on the new numbers."\\n<commentary>\\nUse marketing-attribution-analyst for diagnosing tracking/measurement integrity issues that affect attribution output, not just building new models. Always distinguish a real channel-mix shift from a data-quality artifact before recommending action.\\n</commentary>\\n</example>★ 32.3k GitHub stars

More from kostja94

SkillAffiliate Marketing Strategykostja94/marketing-skills · by kostja94When the user wants to plan, implement, or optimize affiliate marketing strategy. Also use when the user mentions "affiliate marketing," "affiliate program strategy," "CPS model," "affiliate recruitment," "commission structure," "affiliate partners," "affiliate network," "affiliate tracking," "affiliate commission," or "partner marketing." For affiliate page, use affiliate-page-generator.★ 1k GitHub starsSkillAI Search Traffic Trackerkostja94/marketing-skills · by kostja94When the user wants to track AI search traffic in GA4 or GSC. Also use when the user mentions "AI traffic," "ChatGPT referral," "Perplexity traffic," "AI Overviews," "GA4 AI sources," "AI search analytics," "track AI referrals," "AI search traffic," "Claude traffic," or "how to track AI traffic." For AI SEO strategy, use generative-engine-optimization.★ 1k GitHub starsSkillMobile App Campaign Managerkostja94/marketing-skills · by kostja94When the user wants to run app install ads, user acquisition (UA), or promote mobile apps. Also use when the user mentions "app ads," "app install ads," "UA," "user acquisition," "Google App Campaigns," "Apple Search Ads," "ASA," "UAC," "App Store ads," "Play Store ads," "CPI," or "app promotion." For store listings, use distribution-channels.★ 1k GitHub starsSkillLong-Form Article Writerkostja94/marketing-skills · by kostja94When the user wants to write, generate, or create article body content—blog post body, long-form content, how-to guide, listicle. Also use when the user mentions "write article," "article content," "blog post content," "article body," "long-form content creation," "generate article," "article draft," "how-to guide content," "listicle content," "information gain," or "content density." For single post page structure, schema, and SEO metadata, use article-page-generator. For blog index/listing page, use blog-page-generator. For short ad, landing, or email copy, use copywriting.★ 1k GitHub starsSkillBacklink Profile Analyzerkostja94/marketing-skills · by kostja94When the user wants to analyze backlinks, audit link profile, or identify link issues. Also use when the user mentions "backlink analysis," "backlink audit," "referring domains," "toxic links," "link profile," or "disavow file." For acquisition, use link-building.★ 1k GitHub starsSkillTrademark Detectorkostja94/marketing-skills · by kostja94When the user wants to monitor brand mentions, detect trademark infringement, or set up brand monitoring. Also use when the user mentions "brand monitoring," "brand watch," "trademark watch," "brand mentions," "impersonation detection," "counterfeit detection," or "brand abuse monitoring." For enforcement, use brand-protection.★ 1k GitHub stars