[object Object]

← back to Ads Dashboard

Cycle 8: rewire headline KPIs to real acquisition data (orders/revenue/top-channel/UTM%) — was showing empty campaigns.json zeros

55fe441c005fc4667cb3c6e52a40468fc19edc35 · 2026-08-03 07:03:53 -0700 · Steve Abrams

Files touched

Diff

commit 55fe441c005fc4667cb3c6e52a40468fc19edc35
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Aug 3 07:03:53 2026 -0700

    Cycle 8: rewire headline KPIs to real acquisition data (orders/revenue/top-channel/UTM%) — was showing empty campaigns.json zeros
---
 public/index.html | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/public/index.html b/public/index.html
index 3c1cb98..211ef3e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -110,18 +110,21 @@ async function boot(){
   $('hostChip').textContent = location.host;
   document.title = brand.short || 'Ad-Ops';
 
-  const [ov, spend, camps] = await Promise.all([
-    fetch('/api/overview').then(r=>r.json()),
-    fetch('/api/spend').then(r=>r.json()),
+  const [acq, camps] = await Promise.all([
+    fetch('/api/acquisition').then(r=>r.json()).catch(()=>({present:false})),
     fetch('/api/campaigns').then(r=>r.json()),
   ]);
 
-  // KPIs — every number hrefs to its deeper source
-  const kpis = [
-    { h:'Active Campaigns', v:ov.counts.active, href:'/api/campaigns' },
-    { h:'Total Campaigns', v:ov.counts.campaigns, href:'/api/campaigns' },
-    { h:'Domains Covered', v:ov.counts.domains, href:'/api/brand' },
-    { h:'Spend (7d)', v: spend.present ? ('$'+spend.total_usd) : '$0', href:'/api/spend', when: spend.present?'from cost-ledger':'ledger not present' },
+  // KPIs — driven by REAL acquisition data (30d Shopify orders), every number hrefs to its source
+  const topCh = (acq.channels||[])[0];
+  const tagPct = acq.present && acq.totals.orders ? Math.round((acq.totals.utm_tagged||0)/acq.totals.orders*100) : 0;
+  const kpis = acq.present ? [
+    { h:'Orders (30d)', v: acq.totals.orders, href:'/api/acquisition', when: acq.window },
+    { h:'Revenue (30d, net)', v: '$'+acq.totals.revenue.toLocaleString(), href:'/api/acquisition', when: acq.totals.refunded_netted+' refunds netted' },
+    { h:'Top channel', v: topCh ? topCh.channel : '—', href:'/api/acquisition', when: topCh ? topCh.orders+' orders' : '' },
+    { h:'UTM-tagged', v: tagPct+'%', href:'/api/acquisition', when: (acq.totals.utm_tagged||0)+' of '+acq.totals.orders },
+  ] : [
+    { h:'Orders (30d)', v:'—', href:'/api/acquisition', when:'acquisition unavailable' },
   ];
   $('kpis').innerHTML = kpis.map(k=>`<div class="card"><h2>${k.h}</h2>
      <div class="kpi"><a href="${k.href}">${k.v}</a></div>
@@ -137,8 +140,7 @@ async function boot(){
     ? items.map(s=>`<div><a href="${s.url||'#'}">${s.advertiser||s.title||'signal'}</a> <span class="badge">${s.platform||'—'}</span> <span class="when">🕓 ${fmtDate(s.seen_at||s.created_at)}</span></div>`).join('')
     : `<div class="empty">No competitor ad signals captured yet — feeds from the advertising-signals skill. Source: /api/signals</div>`;
 
-  // acquisition — real Shopify order referrers
-  const acq = await fetch('/api/acquisition').then(r=>r.json()).catch(()=>({present:false,reason:'fetch failed'}));
+  // acquisition — real Shopify order referrers (acq already fetched up top for KPIs)
   if (acq.present && (acq.channels||[]).length) {
     $('acqEmpty').hidden = true;
     $('acqBody').innerHTML = acq.channels.map(c=>`<tr>

← 6402086 Cycle 5 fix (Cody): expose capped flag + trend caption (net-  ·  back to Ads Dashboard  ·  honest relabel: 'Shopify rev (30d)' (FMPro $72.7k + PayPal a 33b3919 →