53 lines
2.4 KiB
Markdown
53 lines
2.4 KiB
Markdown
# Analytics dashboard v2
|
|
|
|
Status: Complete
|
|
|
|
## Current state (v1)
|
|
|
|
- Unique visitors, pageviews, bounce rate, visit duration
|
|
- HTML/CSS bar chart with tooltip hover, hourly today view, readable labels
|
|
- 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
|
|
- Period comparison deltas on stat cards (↑12%, ↓3%)
|
|
- Demo seed data spanning 2 years for meaningful comparisons
|
|
|
|
## Improvements (priority order)
|
|
|
|
### 1. Comparison mode
|
|
|
|
~~Compare current period vs previous period.~~ Done (6eda1de). Each stat card shows percentage delta vs equivalent previous period. Handles zero-baseline (shows "new"), caps extreme deltas at >999%. Bounce rate uses inverted colour logic (lower = green). Seed data extended to 2 years.
|
|
|
|
**Files:** `lib/berrypod_web/live/admin/analytics.ex` (date range calc, delta display), `priv/repo/seeds/analytics.exs` (2-year data)
|
|
|
|
### 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
|