# 20 — Advanced Analytics

## Context
Fogbreak replaces Sisu's deep analytics plus adds AI-powered insights none of the 6 replaced platforms offer. This instruction builds the advanced reporting layer on top of the KPI foundation from instruction 06.

## What to Build

### 1. ROI by Lead Source
- Track spend per source (Zillow, Realtor.com, social ads, referrals, open houses, etc.)
- Attribution: source → lead → client → closing → commission
- Cost per lead, cost per closing, ROI per source
- AI recommendations: "Shift budget from Source A (3.2% conversion) to Source B (5.8% conversion)"
- Historical trend per source

### 2. GCI Forecasting
- Pipeline-weighted forecast: each deal stage has a close probability
- Stage probabilities configurable per brokerage
- Monthly/quarterly/annual projections
- Compare forecast to goals
- AI adjusts probabilities based on historical conversion rates for this market

### 3. Agent Profitability
- Revenue per agent (GCI)
- Cost per agent (lead spend, tech fees, splits, marketing)
- Net contribution per agent
- Profitability trend over time
- AI identifies: "Agent X generates $150K GCI but costs $120K in leads — net contribution is low"

### 4. Market Analytics
From MLS data (instruction 18):
- Price trends by neighborhood
- Inventory levels and absorption rate
- Days on market trends
- List-to-sale price ratio
- Seasonal patterns
- Comparative market analysis (CMA) generation

### 5. Conversion Funnel Analysis
Deep funnel metrics:
- Lead → Contact rate (speed to lead)
- Contact → Appointment rate
- Appointment → Showing rate
- Showing → Offer rate
- Offer → Acceptance rate
- Acceptance → Closing rate
- Drop-off analysis at each stage
- Stage duration averages

### 6. Custom Report Builder
- Drag-and-drop report builder
- Select metrics, dimensions, filters, date range
- Chart type selection (bar, line, pie, table)
- Save as template
- Schedule automated report delivery (weekly email)
- Export to PDF/CSV

### 7. AI Insights Engine
Proactive insights surfaced on dashboard:
- "Your showing-to-offer ratio dropped 15% this month. Feedback data suggests pricing is the issue."
- "Agent Y's response time is 4 hours average — leads assigned to them convert at half the team rate."
- "Zillow leads have a 45-day average close time. Realtor.com leads take 62 days. Adjust your pipeline expectations."
- "Based on current pipeline, you'll hit 78% of Q2 GCI goal. Need 3 more listings to close the gap."

### 8. Benchmarking
Compare brokerage performance against:
- Own historical performance
- Market averages (from MLS data)
- Industry benchmarks (configurable)

## Acceptance Criteria
- [ ] ROI tracking and reporting by lead source
- [ ] GCI forecasting with pipeline-weighted probabilities
- [ ] Agent profitability analysis
- [ ] Market analytics from MLS data
- [ ] Conversion funnel analysis with drop-off detection
- [ ] Custom report builder with save/schedule/export
- [ ] AI insights engine with proactive recommendations
- [ ] Benchmarking against historical and market data
