Fix click-to-call conversion counting for Vodafone/Lowi campaigns

Meta API uses click_to_call_call_confirm (not call_confirm) for llamadas
campaigns. Vodafone had 32 and Lowi had 3 confirmed calls not being counted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jose Manuel 2026-06-13 23:25:45 +02:00
parent e4840467c6
commit 184b9ca4a5

View File

@ -24,12 +24,17 @@ class MetaAdsClient:
@staticmethod @staticmethod
def _count_conversions(actions: list) -> float: def _count_conversions(actions: list) -> float:
"""Prioritize 'lead' to avoid double-counting with lead_grouped; include call_confirm.""" """Prioritize 'lead' to avoid double-counting with lead_grouped; include click-to-call."""
by_type = {a["action_type"]: float(a["value"]) for a in actions} by_type = {a["action_type"]: float(a["value"]) for a in actions}
if "lead" in by_type: if "lead" in by_type:
return by_type["lead"] return by_type["lead"]
if "onsite_conversion.lead_grouped" in by_type: if "onsite_conversion.lead_grouped" in by_type:
return by_type["onsite_conversion.lead_grouped"] return by_type["onsite_conversion.lead_grouped"]
# Click-to-call campaigns (Llamadas): click_to_call_call_confirm o call_confirm_grouped
if "click_to_call_call_confirm" in by_type:
return by_type["click_to_call_call_confirm"]
if "call_confirm_grouped" in by_type:
return by_type["call_confirm_grouped"]
return by_type.get("call_confirm", by_type.get("contact", 0.0)) return by_type.get("call_confirm", by_type.get("contact", 0.0))
def _parse_insights_row(self, row: dict) -> dict: def _parse_insights_row(self, row: dict) -> dict: