Files
supermarket/internal/web/templates/metrics-spend.html
T
davidandClaude Opus 5.5 a9a1cb97ac Phase 4 part 4: the spend log and CAC
Spend by month and channel (the funnel's channels and general), by hand
or from pasted CSV (all or nothing); origami.chat and explee.com campaign
spend added hourly as the difference since last seen. CAC per month and
over three months, and per channel over 12 months from each new
customer's first funnel step; unknown, not $0, without spend. Metrics →
Spend and CAC. Schema 21.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:45:49 -07:00

53 lines
3.5 KiB
HTML

{{define "content"}}{{with .Data}}{{$d := .}}
<div class="heading"><h1>Spend and CAC</h1></div>
<p class="lede">What it costs to win a paying customer: the month's marketing and sales spend over the customers who first paid that month. Stripe has no spend, so log it here: by hand, from a CSV, or automatically for origami.chat and explee.com campaigns. Channel CAC uses each new customer's first step in the funnel (a reply, a visit, an outreach email…), matched by email.</p>
<section class="card">
<h2>CAC by month</h2>
<div class="table-wrap"><table class="list compact">
<thead><tr><th>Month</th><th class="num">Spend</th><th class="num">New customers</th><th class="num">CAC</th><th class="num">CAC, 3 months</th></tr></thead>
<tbody>{{range .Months}}<tr><td>{{.Month}}</td><td class="num">{{if .Spend}}{{money .Spend}}{{else}}<span class="muted">·</span>{{end}}</td><td class="num">{{.New}}</td>
<td class="num">{{if .Spend}}{{cents .CAC}}{{else}}<span class="muted">no spend logged</span>{{end}}</td><td class="num">{{cents .Trailing3}}</td></tr>{{end}}</tbody>
</table></div>
<p class="help">One month's CAC swings with a handful of customers; the three-month figure is steadier.</p>
</section>
{{with .CAC.Channels}}
<section class="card">
<h2>By channel, last 12 months</h2>
<table class="list compact">
<thead><tr><th>Channel</th><th class="num">Spend</th><th class="num">New customers</th><th class="num">CAC</th></tr></thead>
<tbody>{{range .}}<tr><td>{{spendChannel .Channel}}</td><td class="num">{{money .Spend}}</td><td class="num">{{.New}}</td><td class="num">{{cents .CAC}}</td></tr>{{end}}</tbody>
</table>
<p class="help">{{if $d.CAC.Unknown}}{{$d.CAC.Unknown}} new customers had no step in the funnel before paying, so their channel is unknown. {{end}}General spend counts in the monthly CAC, not in any one channel's.</p>
</section>
{{end}}
<form method="post" action="/metrics/spend" class="card">
<h2>Log spend</h2>
<div class="row wrap">
<label class="small">Month <input name="month" value="{{.This}}" size="8" placeholder="YYYY-MM"></label>
<label class="small">Channel <select name="channel">{{range .Channels}}<option value="{{.ID}}">{{.Label}}</option>{{end}}</select></label>
<label class="small">Amount <input name="amount" inputmode="decimal" size="9" placeholder="e.g. 250"></label>
<label class="small grow">Note <input name="note" placeholder="optional: what it was"></label>
<button type="submit" class="small">Add</button>
</div>
</form>
<form method="post" action="/metrics/spend" class="card">
<h2>Import from CSV</h2>
<p class="help">Paste rows of <code>month,channel,amount,note</code>, e.g. <code>2026-10,LinkedIn,320,ads</code>. A header row is skipped; nothing is added unless every row is good.</p>
<textarea name="csv" rows="4" class="mono" placeholder="month,channel,amount,note"></textarea>
<div class="actions"><button type="submit" class="secondary small">Import</button></div>
</form>
{{if .Log}}
<h2>The log</h2>
<table class="list compact">
<thead><tr><th>Month</th><th>Channel</th><th class="num">Amount</th><th>Note</th><th>From</th><th></th></tr></thead>
<tbody>{{range .Log}}<tr><td>{{.Month}}</td><td>{{spendChannel .Channel}}</td><td class="num">{{money .AmountCents}}</td><td class="small">{{.Note}}</td><td class="small muted">{{.Source}}</td>
<td><form method="post" action="/metrics/spend/{{.ID}}/delete" data-confirm="Delete this entry?"><button type="submit" class="link small">delete</button></form></td></tr>{{end}}</tbody>
</table>
{{end}}
{{end}}{{end}}