Abstract
The Leads Pipeline is the Apex module responsible for capturing, attributing, and displaying visitor conversions across iSM-network sites. A first-touch attribution pixel, form proxy routes, and the AI concierge all feed a unified ingest endpoint that handles SES notification email, DynamoDB storage, and source attribution in a single call.
Problem
Leads arriving through organic search, AI referrals, paid ads, and contact forms need a unified attribution model that survives across sessions and can be queried later by campaign, source, and page. A site-specific lead handler solves the immediate notification problem but produces siloed data with no cross-channel view.
Sending notification emails per-site also requires each site to have its own verified SES domain, DKIM, and SPF setup — operationally expensive to maintain as the network grows.
Approach
Attribution capture
The Apex pixel (`apex.js`) sets a first-touch _apex_src cookie with source, medium, landing page, and timestamp. When a visitor submits a contact form, the site's thin proxy route passes the form data, attribution cookie, and geo metadata to `POST /api/leads/submit` on Apex.
The submit endpoint handles both the DynamoDB write and the SES notification in a single call — no per-site email infrastructure required.
Lead storage
Lead records store the full attribution chain: source, medium, campaign, gclid, ai_referrer, and landing_page. A daily LEADSUMMARY record aggregates totals by source, form, and page.
Google Ads campaign data syncs daily via a 6am CT cron, enabling spend-to-lead attribution.
Dashboard
The dashboard presents four tabs: Overview (KPI cards, donut chart, daily trend, lead feed), Journey (Sankey diagram of source → landing page → conversion), Coverage (Mapbox lead geography heatmap), and Google Ads (campaign table with spend, CTR, CPC, and conversions).
Status
- Live on multiple iSM-network sites with pixel, proxy routes, and attribution flowing.
- Push notifications (Expo + Web Push) fire on every new lead.
- Google Ads sync active for tenants with a Google Ads customer ID configured.
- Rate limit: 100 leads/day per tenant; PII nulled server-side for medical tenants.