DEV Community

Thesius Code
Thesius Code

Posted on • Originally published at datanest-stores.pages.dev

E-Commerce Analytics Dashboard

E-Commerce Analytics Dashboard

Comprehensive analytics framework with sales dashboards, customer cohort analysis, conversion funnel tracking, revenue forecasting, and automated KPI alerting. Turn raw e-commerce data into executive-ready insights.

Key Features

  • Sales Analytics — Daily/weekly/monthly revenue, AOV, units sold with trend detection
  • Cohort Analysis — Customer retention curves by acquisition month
  • Conversion Funnels — Multi-step funnel visualization from visit → cart → checkout → purchase
  • Revenue Forecasting — Moving-average and exponential smoothing projections
  • KPI Alerting — Rule-based alerts when metrics breach thresholds
  • Dashboard Configs — Pre-built JSON dashboard definitions for rapid deployment

Quick Start

# 1. Extract and configure
unzip ecommerce-analytics-dashboard.zip
cd ecommerce-analytics-dashboard
cp config.example.yaml config.yaml

# 2. Generate sample dashboard data
python -m ecommerce_analytics.generate_sample --output ./data/

# 3. Run the analytics pipeline
python -m ecommerce_analytics.core --config config.yaml
Enter fullscreen mode Exit fullscreen mode

Architecture

├── config.example.yaml        # Main configuration
├── alerts/rules.yml           # KPI alert thresholds and notification rules
├── dashboards/main.json       # Dashboard layout and widget definitions
└── src/ecommerce_analytics/
    ├── core.py                # Pipeline orchestrator
    ├── cohorts.py             # Cohort retention calculations
    ├── funnels.py             # Funnel stage tracking
    └── forecasting.py         # Time-series forecasting models
Enter fullscreen mode Exit fullscreen mode

Usage Examples

Sales Summary Query

-- Daily sales KPI summary
SELECT
    DATE(order_date)                          AS sale_date,
    COUNT(DISTINCT order_id)                  AS total_orders,
    SUM(order_total)                          AS gross_revenue,
    SUM(order_total) / COUNT(DISTINCT order_id) AS avg_order_value,
    COUNT(DISTINCT customer_id)               AS unique_buyers
FROM orders
WHERE order_status IN ('completed', 'shipped')
  AND order_date >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY DATE(order_date)
ORDER BY sale_date DESC;
Enter fullscreen mode Exit fullscreen mode

Cohort Retention

from ecommerce_analytics.cohorts import CohortAnalyzer

analyzer = CohortAnalyzer(period="monthly")
cohort_matrix = analyzer.build_retention_matrix(orders)

# cohort_matrix is a dict: {cohort_month: {period_0: 100%, period_1: 42%, ...}}
for cohort, retention in list(cohort_matrix.items())[:2]:
    print(f"Cohort {cohort}: M0={retention[0]:.0%}, M1={retention[1]:.0%}, M2={retention[2]:.0%}")
Enter fullscreen mode Exit fullscreen mode

Conversion Funnel

from ecommerce_analytics.funnels import FunnelTracker

funnel = FunnelTracker(stages=[
    "page_view", "add_to_cart", "begin_checkout", "purchase"
])

results = funnel.analyze(events, date_range=("2026-03-01", "2026-03-23"))
for stage in results:
    print(f"{stage['name']}: {stage['count']:,} ({stage['conversion_rate']:.1%})")
# page_view: 50,000 (100.0%)
# add_to_cart: 8,500 (17.0%)
# begin_checkout: 3,400 (6.8%)
# purchase: 1,700 (3.4%)
Enter fullscreen mode Exit fullscreen mode

Revenue Forecasting

from ecommerce_analytics.forecasting import RevenueForecaster

forecaster = RevenueForecaster(method="exponential_smoothing", alpha=0.3)
forecast = forecaster.predict(daily_revenue, horizon_days=30)

print(f"Next 30-day projected revenue: ${sum(forecast):,.2f}")
Enter fullscreen mode Exit fullscreen mode

Configuration

analytics:
  date_range: "last_90_days"     # Lookback window for dashboards
  granularity: "daily"           # daily | weekly | monthly
  currency: "USD"

cohorts:
  period: "monthly"              # monthly | weekly
  min_cohort_size: 50            # Exclude cohorts below this threshold

funnels:
  session_timeout_minutes: 30    # Max gap between funnel steps
  stages: ["page_view", "add_to_cart", "begin_checkout", "purchase"]

alerts:
  enabled: true
  rules:
    - metric: "daily_revenue"
      condition: "below"
      threshold: 500
      notify: "email"
    - metric: "conversion_rate"
      condition: "below"
      threshold: 0.02
      notify: "slack"

forecasting:
  method: "exponential_smoothing"  # moving_average | exponential_smoothing
  alpha: 0.3                       # Smoothing factor (0-1)
  horizon_days: 30
Enter fullscreen mode Exit fullscreen mode

Best Practices

  1. Start with daily granularity — Aggregate up to weekly/monthly as needed
  2. Set realistic alert thresholds — Use 2 weeks of baseline data before enabling alerts
  3. Exclude test orders — Filter internal/test transactions to avoid skewing metrics
  4. Cohort minimum sizes — Ignore cohorts with < 50 customers for statistical validity
  5. Forecast regularly — Re-run forecasts weekly to catch trend shifts early

Troubleshooting

Issue Cause Fix
Funnel shows 0% conversion Event names don't match stages config Verify stages list matches your event taxonomy
Cohort matrix has gaps Missing months with no acquisitions Set min_cohort_size: 0 or check data completeness
Forecast flatlines Insufficient history Provide at least 60 days of daily revenue data
Alerts firing constantly Thresholds too aggressive Baseline your metrics, then set thresholds at 2σ below mean

This is 1 of 11 resources in the Retail Automation Pro toolkit. Get the complete [E-Commerce Analytics Dashboard] with all files, templates, and documentation for $49.

Get the Full Kit →

Or grab the entire Retail Automation Pro bundle (11 products) for $139 — save 30%.

Get the Complete Bundle →


Related Articles

Top comments (0)