# Component 2: GA Agent Skill

**Type:** Claude Skill
**Priority:** P0
**Status:** Not Started
**Final Location:** `ourdigital-custom-skills/15-ourdigital-ga-agent/`

## Goal

Interactive GA4 analysis and reporting skill for Claude Code.

## Features

| Feature | Description |
|---------|-------------|
| Traffic Analysis | Users, sessions, pageviews with trends |
| Period Comparison | WoW, MoM, YoY comparisons |
| Top Content | Pages, sources, campaigns |
| Report Generation | HTML reports |
| BigQuery Queries | Complex analysis on exported data |

## Triggers

**English:**
- "Analyze GA4 traffic"
- "Compare last week vs this week"
- "Generate traffic report"
- "Top landing pages"
- "Query BigQuery for GA data"

**Korean:**
- "GA4 트래픽 분석"
- "지난주 대비 비교"
- "트래픽 리포트 생성"
- "인기 랜딩 페이지"
- "BigQuery GA 데이터 조회"

## Structure

```
15-ourdigital-ga-agent/
├── SKILL.md                    # Skill definition
├── scripts/
│   ├── analyze_traffic.py      # Traffic analysis
│   ├── compare_periods.py      # Period comparisons
│   ├── top_content.py          # Top pages/sources
│   └── generate_report.py      # HTML report generation
├── templates/
│   └── report.html             # Report template
├── references/
│   └── ga4-api-reference.md    # Quick API reference
└── examples/
    └── sample-queries.md       # Example usage
```

## Dependencies

Requires Component 1 (MCP Setup) to be complete.

## Scripts

### analyze_traffic.py

Fetches traffic metrics for a date range:
- Active users
- Sessions
- Pageviews
- Bounce rate
- Session duration

### compare_periods.py

Compares metrics between two periods:
- Current vs previous period
- Percentage changes
- Trend indicators

### top_content.py

Lists top performing content:
- Landing pages
- Traffic sources
- Campaigns
- Countries/cities

### generate_report.py

Generates HTML report with:
- Summary metrics
- Charts (via Plotly)
- Top content tables
- Period comparison

## Development

```bash
# Work in this directory
cd 02-ga-agent-skill

# Create skill structure
mkdir -p skill/{scripts,templates,references,examples}

# When complete, move to final location
mv skill ../ourdigital-custom-skills/15-ourdigital-ga-agent
```

## Checklist

- [ ] SKILL.md created
- [ ] analyze_traffic.py
- [ ] compare_periods.py
- [ ] top_content.py
- [ ] generate_report.py
- [ ] report.html template
- [ ] Examples documented
- [ ] Tested with Claude Code
- [ ] Moved to ourdigital-custom-skills/
