Drop the Google Ads campaign table from the metrics scorecard.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -431,42 +431,6 @@ export default function MetricsDashboard({
|
||||
return 'CRM';
|
||||
}, [integrations]);
|
||||
|
||||
const googleCampaigns = useMemo(() => {
|
||||
const byCampaign = new Map<
|
||||
string,
|
||||
{ spend: number; impressions: number; clicks: number; leads: number }
|
||||
>();
|
||||
for (const r of rangedDaily) {
|
||||
if (r.platform !== 'google') continue;
|
||||
const name = r.campaign_name || r.campaign || 'Campaña sin nombre';
|
||||
const cur = byCampaign.get(name) || {
|
||||
spend: 0,
|
||||
impressions: 0,
|
||||
clicks: 0,
|
||||
leads: 0,
|
||||
};
|
||||
cur.spend += Number(r.spend) || 0;
|
||||
cur.impressions += Number(r.impressions) || 0;
|
||||
cur.clicks += Number(r.clicks) || 0;
|
||||
cur.leads += Number(r.platform_leads ?? r.conversions) || 0;
|
||||
byCampaign.set(name, cur);
|
||||
}
|
||||
const totalSpend = [...byCampaign.values()].reduce((a, b) => a + b.spend, 0);
|
||||
return [...byCampaign.entries()]
|
||||
.map(([name, v]) => ({
|
||||
name,
|
||||
...v,
|
||||
cpl: v.leads > 0 ? v.spend / v.leads : 0,
|
||||
share: totalSpend > 0 ? (v.spend / totalSpend) * 100 : 0,
|
||||
kind: /pmax|performance/i.test(name)
|
||||
? 'Performance Max'
|
||||
: /search|brand/i.test(name)
|
||||
? 'Búsqueda'
|
||||
: 'Otra red',
|
||||
}))
|
||||
.sort((a, b) => b.spend - a.spend);
|
||||
}, [rangedDaily]);
|
||||
|
||||
const adsCards = cards.filter((c) =>
|
||||
['spend', 'leads', 'cpl'].includes(c.key)
|
||||
);
|
||||
@@ -947,58 +911,6 @@ export default function MetricsDashboard({
|
||||
</p>
|
||||
</section>
|
||||
|
||||
{googleCampaigns.length > 0 && (
|
||||
<section className="bg-white border border-gray-200 rounded-xl p-5 space-y-3 shadow-sm">
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold text-gray-900">
|
||||
5. Campañas Google Ads
|
||||
</h3>
|
||||
<p className="text-xs text-gray-600 mt-0.5">
|
||||
Desglose de la inversión Google del periodo. Meta va en Ads /
|
||||
creatividades. No vuelve a contar el scorecard de arriba.
|
||||
</p>
|
||||
</div>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead className="text-gray-600 border-b border-gray-200">
|
||||
<tr>
|
||||
<th className="py-2 pr-3 font-semibold">Campaña</th>
|
||||
<th className="py-2 pr-3 font-semibold">Red</th>
|
||||
<th className="py-2 pr-3 font-semibold">Inversión</th>
|
||||
<th className="py-2 pr-3 font-semibold">Clics</th>
|
||||
<th className="py-2 pr-3 font-semibold">Conv.</th>
|
||||
<th className="py-2 font-semibold">CPL</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{googleCampaigns.slice(0, 12).map((c) => (
|
||||
<tr
|
||||
key={c.name}
|
||||
className="border-b border-gray-100 hover:bg-gray-50"
|
||||
>
|
||||
<td className="py-2 pr-3 font-medium text-gray-900 max-w-[280px] truncate" title={c.name}>
|
||||
{c.name}
|
||||
</td>
|
||||
<td className="py-2 pr-3 text-gray-600">{c.kind}</td>
|
||||
<td className="py-2 pr-3 tabular-nums">{formatEur(c.spend)}</td>
|
||||
<td className="py-2 pr-3 tabular-nums">{formatNum(c.clicks)}</td>
|
||||
<td className="py-2 pr-3 tabular-nums">{formatNum(c.leads)}</td>
|
||||
<td className="py-2 tabular-nums">
|
||||
{c.cpl > 0 ? `${formatNum(c.cpl)} €` : '—'}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{googleCampaigns.length > 12 && (
|
||||
<p className="text-[11px] text-gray-500">
|
||||
Mostrando 12 de {googleCampaigns.length} campañas (las de más
|
||||
gasto). El resto está en Ads.
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user