How to calculate Cost per Lead (CPL)
Cost per lead is the average marketing spend needed to generate one lead.
Formula
CPL = marketing spend ÷ leads generatedSQL query
This example assumes: spend(month, channel, amount), leads(id, channel, created_at). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.
SELECT s.channel,
s.spend,
l.leads,
s.spend / NULLIF(l.leads, 0) AS cost_per_lead
FROM (SELECT channel, SUM(amount) AS spend FROM spend
WHERE month >= DATE '2026-07-01' GROUP BY channel) s
LEFT JOIN (SELECT channel, COUNT(*) AS leads FROM leads
WHERE created_at >= DATE '2026-07-01' GROUP BY channel) l
USING (channel)
ORDER BY cost_per_lead;Common mistakes that make Cost per Lead (CPL) wrong
- A cheap lead that never converts is worse than an expensive one that does; read CPL next to conversion rate.
- Duplicate leads from the same person lower CPL artificially.
- Channels with spend but zero leads divide by zero; keep them visible instead of dropping them.
Ask for Cost per Lead (CPL) in plain English
Instead of writing the query yourself, you can type the question. SchemaChat turns it into SQL against your connected database or uploaded file, runs it, and shows the SQL and the figures it used so you can check the answer before you share it. It does not replace your judgement about the definition: check that the query matches the formula your business uses.
- What is our cost per lead by channel this quarter?
- Which channel produced leads at the lowest cost?