Customer Retention Analytics Dashboard

2025-12-14

Demo (Streamlit) | GitHub

alt

A Streamlit application for analyzing customer retention patterns using cohort analysis.

Features

  • Multiple cohort analysis types:
    • Unique Customers
    • Percentage Retention
    • Average Order Value (AOV)
  • Flexible time period selection with yearly cutoffs
  • Key metrics tracking:
    • AOV with period-over-period comparison
    • New customers per month with growth metrics
    • Existing customers per month with growth metrics
  • Interactive heatmap visualization

Required Data Format

The application expects a CSV file with the following columns:

  • transaction_datetime: Date of the transaction
  • transaction_id: Unique identifier for each transaction
  • customer_id: Unique identifier for each customer
  • transaction_value: Monetary value of the transaction

Setup

  1. Create a virtual environment:

    python -m venv venv
    
  2. Activate the virtual environment:

    • Windows:
      .\venv\Scripts\activate
      
    • Unix/MacOS:
      source venv/bin/activate
      
  3. Install dependencies:

    pip install -r requirements.txt
    

Running the Application

  1. Activate the virtual environment (if not already activated)

  2. Run the Streamlit app:

    streamlit run app.py
    
  3. Upload your CSV file and start analyzing!

Usage

  1. Upload your transaction data CSV file
  2. Select the cohort type (Unique Customers, Percentage, or AOV)
  3. Choose the start year and month for the analysis period
  4. Filter by customer ranks if desired
  5. Analyze the results in the interactive dashboard

The heatmap shows retention patterns over time, with darker colors indicating higher values. The metrics at the top show period-over-period comparisons for key business indicators.

If you don’t have real transaction data yet, this repo includes a notebook to generate a realistic dummy dataset for testing.

  1. Make sure your virtual environment is activated and dependencies are installed.

    pip install -r requirements.txt
    
  2. Open the notebook.

    jupyter notebook
    
  3. Run all the cells. The notebook will generate a CSV file (e.g. dummy_transactions.csv) in the project folder.