Search by

jaizendra-netizen / customer-churn-report

onegtmlab

Customer churn and revenue churn for a period from a customers CSV, split by segment, cohort and reason.

Package info

github.com/jaizendra-netizen/customer-churn-report

Homepage

Type:project

pkg:composer/jaizendra-netizen/customer-churn-report

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-27 20:49 UTC

This package is not auto-updated.

Last update: 2026-11-28 22:38:37 UTC


README

A small PHP command-line tool (PHP 8.1 or later, no dependencies) for the definition on the GTM glossary page What Is Churn Rate? Definition and Formula.

The page defines churn rate as the percentage of customers, or of recurring revenue, a company loses over a period through cancellations or non-renewals. It separates customer churn (lost accounts) from revenue churn (lost recurring revenue), notes that the two can differ when large and small customers leave at different rates, gives the common formula (customers lost during a period divided by customers at its start), and says teams look at churn by segment, cohort and reason. This tool does exactly that from a CSV. The page was read on 28 Nov 2026.

What it does

Input is a CSV with the columns customer_id, segment, start_date, cancel_date, cancel_reason, mrr (dates as YYYY-MM-DD, an empty cancel_date means still a customer). For a period it prints:

  • customers at the start, customers lost, customer churn (lost divided by customers at the start);
  • recurring revenue at the start, recurring revenue lost, revenue churn;
  • a plain sentence saying whether the leavers were smaller or larger than the average customer;
  • optional breakdowns --by segment, --by cohort (start quarter) and --by reason.

Choices the page does not spell out, so they are this tool's own: "at the start" means started before the first day and not cancelled before it; customers who start inside the period are left out of the denominator; a cancel date on or before the last day counts as lost; with no customers at the start the churn is "n/a", not 0.

php bin/churn-report --file examples/customers.csv --from 2026-01-01 --to 2026-03-31 --by segment,reason,cohort

Test

php tests/run.php
sh examples/run.sh

The tests rebuild the page's own example (400 customers at the start, 20 cancel, 5 percent customer churn, with small leavers so revenue churn is lower), then check the edge cases above and the CSV validation. Everything in examples/customers.csv is made-up data. MIT licensed.