- analytics-v2 plan with prioritised improvements (comparison mode, filtering, CSV export, entry/exit pages) - seed script generating ~35k realistic events over 12 months (weighted traffic, referrers, devices, e-commerce funnel) - funnel chart now shows overall conversion rate from product views instead of step-to-step percentages - summary line with overall conversion rate and revenue Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2.2 KiB
Analytics dashboard v2
Status: Planned
Current state (v1)
- Unique visitors, pageviews, bounce rate, visit duration
- SVG bar chart for visitor trends
- Date range picker (Today, 7d, 30d, 12m)
- Top pages, sources/referrers, countries, devices
- E-commerce conversion funnel (product view → cart → checkout → purchase)
- Data collection: UTMs, referrers, browser, OS, screen size, full e-commerce funnel
Improvements (priority order)
1. Comparison mode
Compare current period vs previous period. Show deltas on each metric (↑12%, ↓3%). Already have date ranges — just query the previous period in parallel and render the difference. Low effort, high value.
Files: lib/berrypod/analytics.ex (queries), lib/berrypod_web/live/admin/analytics.ex (UI)
2. Dashboard filtering
Click any referrer, country, device, or page to filter the whole dashboard by that dimension. Turns a reporting page into an exploration tool. Single most useful feature for understanding traffic.
Approach: Add filter params to the URL (e.g. ?country=GB&source=twitter.com), thread them through all queries. Render active filters as dismissible chips.
Files: analytics context (all query functions), analytics LiveView (params, UI)
3. CSV export
Export current dashboard view (respecting date range and filters) as CSV. Dead simple, always requested.
Approach: Add a download button per panel (or one global export). Use a regular controller route that streams CSV.
Files: new controller or plug for CSV response, analytics context for raw data queries
4. Entry/exit pages
Which pages people land on and leave from. Data likely already exists (first and last pageview per session). Just needs the query and a UI panel.
Files: analytics context (new queries), analytics LiveView (new panel)
Future (lower priority)
- Real-time dashboard — live visitor count, active pages (needs PubSub or polling)
- Line charts — proper time-series with date axes (replace bar chart)
- UTM drill-downs — campaign/medium/source breakdown views
- Goals/custom events — user-defined conversion tracking
- Stats API — JSON API for embedding elsewhere