Phase 4 part 5: CLV and revenue by cohort
CLV = ARPA × revenue-weighted gross margin ÷ customer churn averaged over up to 12 complete months, with lifetime and CLV:CAC (CAC over its own 12-month window). Revenue by cohort from money that came in: paid invoices less refunds and post-payment credits not refunded, cumulative per customer, with a gross profit view; months not reached are told apart from negative amounts. Metrics → CLV and cohorts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -400,3 +400,28 @@ func (s *Server) metricsSpendDelete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
redirect(w, r, "/metrics/spend", "deleted")
|
||||
}
|
||||
|
||||
// --- CLV and cohorts ---
|
||||
|
||||
func (s *Server) metricsCLV(w http.ResponseWriter, r *http.Request) {
|
||||
now := time.Now()
|
||||
model, err := metrics.Build(s.DB, now)
|
||||
if err != nil {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
clv, err := metrics.BuildCLV(s.DB, model, now)
|
||||
if err != nil {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
cohorts, err := metrics.RevenueByCohort(s.DB, model, 18, 12, now)
|
||||
if err != nil {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
s.render(w, r, "metrics-clv", page{Title: "CLV and cohorts", Nav: "metrics/clv", Data: map[string]any{
|
||||
"CLV": clv, "Cohorts": cohorts, "Span": make([]int, 13), "Profit": r.URL.Query().Get("view") == "profit",
|
||||
"Currency": model.Currency,
|
||||
}})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user