Epic 4 - Analytics & Metrics
Epic 4 implements analytics and metrics tracking for audio generations and QR code scans.
Objective
Add analytics and metrics tracking to measure user engagement, QR code scans, and audio playback.
What You Track:
- Total QR codes generated
- Total scans per QR code
- Total audio listens (direct URL and QR scans)
- Geographic distribution of scans
- Time-based usage patterns
- Device types (mobile vs desktop)
What You Get:
- Analytics dashboard
- Real-time metrics
- User engagement insights
- Investor-ready reports
- CSV/Excel exports
Epic 4 adds analytics to the complete system built in Epic 1 (audio), Epic 2 (QR codes), and Epic 3 (manual upload).
Priorities Covered
- P5: Basic Analytics (Scans/Listens)
Prerequisites:
- Epic 1: Audio generation working
- Epic 2: QR code generation working
- Epic 3: Manual upload working
Features
Analytics Dashboard
Real-Time Metrics:
- Total users registered
- Total audio generations created
- Total QR codes generated
- Total scans across all QR codes
- Total audio listens
User Dashboard:
- Personal generation history
- Scans per generation
- Most popular content
- Geographic scan distribution
- Usage over time (charts)
Admin Dashboard:
- Platform-wide metrics
- Growth charts and trends
- System health indicators
- User engagement metrics
- Error rates and alerts
Tracking Features
QR Code Scan Tracking:
- Track each scan via QR code
- Capture device type
- Capture location (city/country)
- Capture timestamp
- Link to specific generation
Audio Play Tracking:
- Track direct URL plays
- Track QR code plays
- Capture listen duration
- Capture completion rate
- Identify repeat listeners
User Engagement:
- Generation frequency
- Average listens per generation
- Peak usage times
- Popular voice models
- Content length patterns
Technical Details
Data Storage
Track the following metrics:
Scans Table:
- Scan ID
- Generation ID
- Timestamp
- Device type (mobile/desktop)
- Location (city, country)
- Referrer (QR scan vs direct link)
Plays Table:
- Play ID
- Generation ID
- Timestamp
- Duration listened
- Completion percentage
- Device type
Aggregated Metrics:
- Total scans per generation
- Total plays per generation
- Average listen duration
- Popular content
- Geographic heatmap data
Analytics API
Get Generation Analytics
Endpoint: GET /api/v1/analytics/generation/{id}
Response:
{
"success": true,
"data": {
"generationId": "550e8400-e29b-41d4-a716-446655440000",
"totalScans": 127,
"totalPlays": 98,
"avgListenDuration": 12.5,
"topLocations": [
{"city": "New York", "country": "USA", "scans": 45},
{"city": "London", "country": "UK", "scans": 32}
],
"deviceBreakdown": {
"mobile": 89,
"desktop": 38
},
"scansByDay": [
{"date": "2024-11-01", "scans": 23},
{"date": "2024-11-02", "scans": 31}
]
}
}
Get User Analytics
Endpoint: GET /api/v1/analytics/user
Response:
{
"success": true,
"data": {
"totalGenerations": 24,
"totalScans": 450,
"totalPlays": 367,
"mostPopular": {
"generationId": "550e8400...",
"text": "Welcome to our restaurant...",
"scans": 127
},
"recentActivity": [
{"date": "2024-11-03", "generations": 3, "scans": 18}
]
}
}
Success Criteria
Epic 4 is complete when:
- ✅ QR code scans are tracked
- ✅ Audio plays are tracked
- ✅ Manual upload listens are tracked
- ✅ User dashboard shows personal analytics
- ✅ Admin dashboard shows platform metrics
- ✅ Geographic data is captured
- ✅ Device type is tracked
- ✅ CSV/Excel export works
- ✅ Real-time metrics update
- ✅ Manual testing completed and verified
- ✅ Deployed to production
Timeline
Duration: 5 weeks
| Weeks | Focus | Deliverables |
|---|---|---|
| Week 17 | Analytics Infrastructure | Tracking events implemented |
| Week 18 | Data Storage & API | Analytics API endpoints |
| Week 19 | User Dashboard | Personal analytics view |
| Week 20 | Admin Dashboard | Platform-wide analytics |
| Week 21 | Reports & Export | CSV export and testing |
Dashboard Mockup
User Dashboard
Personal Metrics:
- Total Generations: 24
- Total Scans: 450
- Total Plays: 367
- This Month: +15 generations
Top Performing Content:
- "Welcome to our restaurant..." - 127 scans
- "Special holiday menu..." - 89 scans
- "New summer menu items..." - 67 scans
Recent Activity Chart:
- Line chart showing scans over the last 30 days
- Bar chart showing plays by day of week
Admin Dashboard
Platform Metrics:
- Total Users: 342
- Total Generations: 5,847
- Total Scans: 45,231
- Total Plays: 38,904
- Growth: +23% this month
System Health:
- API Response Time: 145ms avg
- Error Rate: 0.02%
- S3 Storage: 234 GB used
- ElevenLabs Usage: 87% of quota
Export Formats
CSV Export
Generate CSV reports with:
- Generation details (text, voice, date)
- Scan counts per generation
- Play counts per generation
- Geographic breakdown
- Date range filtering
Example CSV:
Generation ID,Text,Voice,Created,Scans,Plays,Top Location
550e8400...,Welcome to our restaurant,Rachel,2024-11-01,127,98,"New York, USA"
660e8400...,Special holiday menu,Adam,2024-11-02,89,72,"London, UK"
Excel Export
Same data as CSV but with:
- Multiple sheets (Overview, Scans, Plays, Locations)
- Charts and visualizations
- Formatted tables
- Summary statistics
Related Documentation
- Epic 1 Overview - Audio generation prerequisites
- Epic 2 Overview - QR code generation prerequisites
- Epic 3 Overview - Manual upload prerequisites
- MVP Priorities - P5 Analytics details
- System Architecture - Complete architecture