Cost per lead (CPL) for Meta is cost divided by one lead column, such as extra.actions.lead, after both have been summed over the rows you report on. etlmcp's conversions column counts purchases, not leads, so its cpa is a cost per purchase and is no use on a lead campaign. When the Meta connector is available, every action type Meta reports lands in its own extra.actions.<type> column. Work out CPL in the pipeline with a group rule and derive rules, or in SQL in your destination, and follow four rules: use one lead type, divide only totals, treat a missing lead count as zero, and never divide by zero.
Step 1: choose one lead column
Meta reports leads under several action types that overlap. Its Ads Action Stats reference describes lead as offsite leads plus on-Facebook leads, onsite_conversion.lead_grouped as all on-Facebook leads, leadgen_grouped as on-Facebook leads from Messenger and Instant Forms, and offsite_conversion.fb_pixel_lead simply as leads. An Instant Form lead is therefore counted in three of those columns at once.
Pick the single column that matches where your leads happen, and divide by that column alone. Do not add a second lead type to it: extra.actions.lead + extra.actions.leadgen_grouped counts every Instant Form lead twice and makes your CPL look lower than it is. Meta lead action types explains which column answers which question. This recipe uses extra.actions.lead; swap in the column you chose.
Step 2: sum first, then divide
CPL over a week, a campaign or an account is total cost divided by total leads. It is not the average of each row's CPL. Take two days of one campaign: 100 spent for 10 leads (CPL 10), then 20 spent for 1 lead (CPL 20). The true CPL is 120 divided by 11, about 10.9. The average of the two daily figures is 15, because it gives the cheap day with one lead the same weight as the day with ten.
Never total a CPL column with an average, including a group rule set to avg. Sum cost and leads, then divide.
Step 3: a missing lead count is zero
A row carries a lead column only when Meta reported that action for that ad and day. etlmcp writes no zero into an action column Meta did not send, so an ad that spent money and got no leads has an empty lead cell, not a 0. When you add leads up, treat the empty value as zero. When you divide, a total of zero leads has no CPL: show it as empty, not as zero and not as an error.
In the pipeline: a group rule, then derive rules
Order matters. A group rule keeps only its by columns, the common metrics, its own ratios and the numeric extra columns, so a column you derive before the group is dropped. Group first, then derive:
[
{"op": "group", "by": ["date", "campaign_id", "campaign_name"]},
{"op": "derive", "as": "leads", "expr": "extra.actions.lead + 0"},
{"op": "derive", "as": "cpl", "expr": "cost / leads"}
]
- group adds up
costand the numericextracolumns within each date and campaign. Rows that lackextra.actions.leadadd nothing to its total, which is the same as counting them as zero. Keepingdateinbykeeps one row per day, so each run still replaces only the days it covers. If no row in a group had a lead, the group's row has noextra.actions.leadat all. - derive
leadsturns that missing value into 0. In etlmcp's expressions, addition treats an empty value as 0, soextra.actions.lead + 0is the lead count, or 0 when Meta reported none. - derive
cpldivides cost by leads. etlmcp's division returns an empty value when the divisor is 0 or empty, instead of failing the run, so a campaign day with spend and no leads gets an emptycpl.
The cpl here is still per campaign and per day. When you report a longer period, sum cost and leads again and divide, as in Step 2; do not average cpl.
In PostgreSQL: sum, then divide
If you keep the raw rows, work CPL out in the query. In PostgreSQL the extra columns keep their dotted names, so each needs double quotes. Without a group rule, etlmcp creates a Meta action column as text, and a derived column such as cpl is always text, so cast before you add up. Replace meta_ads with your table's name:
SELECT
campaign_name,
SUM(cost) AS spend,
SUM(COALESCE("extra.actions.lead"::double precision, 0)) AS leads,
SUM(cost)
/ NULLIF(SUM(COALESCE("extra.actions.lead"::double precision, 0)), 0) AS cpl
FROM meta_ads
WHERE date BETWEEN '2026-11-01' AND '2026-11-30'
GROUP BY campaign_name
ORDER BY spend DESC;
COALESCE returns its first argument that is not null, so an empty lead cell counts as 0. PostgreSQL's NULLIF returns null when its two arguments are equal, so a campaign with no leads gets a null cpl instead of a division-by-zero error. The cast also works when the column is already a number. If the table was first created by a pipeline with a group rule, the lead column is a number; a column keeps the type it was created with.