fix: Ads Meta conv/CPL = Clientes potenciales (sin sumar acciones solapadas)
Las creatividades inflaban ~3× al sumar lead + lead_grouped + registration. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
20
src/lib/meta-leads.ts
Normal file
20
src/lib/meta-leads.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/** Meta Ads «Clientes potenciales» ↔ platform_leads (same metric as Ads Manager). */
|
||||
|
||||
export function nMeta(v: unknown): number {
|
||||
const x = Number(v);
|
||||
return Number.isFinite(x) ? x : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exact Ads Manager «Clientes potenciales» for Meta Leads CRM campaigns.
|
||||
* Do not sum lead / lead_grouped / pixel — those overlap and inflate totals.
|
||||
*/
|
||||
export function leadFromMetaActions(
|
||||
actions?: { action_type?: string; value?: string }[]
|
||||
): number {
|
||||
if (!actions?.length) return 0;
|
||||
const primary = actions.find(
|
||||
(a) => a.action_type === 'offsite_complete_registration_add_meta_leads'
|
||||
);
|
||||
return primary ? nMeta(primary.value) : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user