Single brand: MortgageCo. Single parent offer: hefty.offers.id=32.
Eleven children (ids 12-22) โ one per buyer/network we resell leads to.
Every Meta/Google/Email click lands on go.mortgageco.com/?aff=8&oid=32&... โ parent oid=32
is routed to a child offer before being stored, so the parent never owns clicks directly.
Real user lands on the canonical tracking link:
https://go.mortgageco.com/?aff=8&oid=32&s1={{campaign.id}}&s2={{adset.id}}&s3={{ad.id}}&fbclid={{fbclid}}
Nginx on slaives proxies the click to the click-ingest service on port 3033. Service inserts a row into hefty.clicks (partner_id=8, offer_id=<routed child>).
App layer routes parent 32 โ child via pickRoutedOfferIdOrDefault(), walking hefty.offer_hierarchy. DB trigger trg_clicks_block_parent_offer enforces this at the DB layer.
User completes the multi-step funnel on go.mortgageco.com. Final POST hits https://hefty.cc/api/leads/ingest with click_id, PII (email/phone/first/last/state/zip), and Meta tracking params. Heftycc creates the hefty.leads row with click_row_id FK to the click, inheriting partner_id. PR #25 + #27 ensure body-level aff/utm_source/fbclid/numeric s1 override the organic fallback so attribution is correct even when the referrer is stripped.
distributeLead() iterates hefty.buyers by priority. Each buyer's delivery_url is POSTed with the lead payload. First buyer to accept (HTTP 200 + parsed accept response) marks the lead status='sold'. Buyers in multi_sell_eligible mode also receive the lead. Each acceptance writes to hefty.lead_distributions:
lead_id, buyer_id, accepted=true, price=<negotiated>, http_status, response_time_ms
Each buyer's child offer assignment (buyer โ child offers.id 12-22) lives in hefty.buyers.offer_id OR hefty.partner_buyer_routing. The buyer's accepted price = gross revenue in the dashboard (lead_distributions.price).
When a buyer's downstream funnel converts, they fire a GET to:
https://hefty.cc/api/postback?click_id=...&offer_id=...&payout=...&transaction_id=...&status=approved
The /api/postback handler:
click_id (hex UUID from the original click).offer_id (12โ22).hefty.offer_conversions (click_id, offer_id, payout, status='approved', transaction_id).hefty.postback_logs.Postback payout = net revenue (what the buyer actually paid per their postback rules). Some buyers post back per-acceptance (immediate), some per-final-funded (delayed).
If the lead was sourced from an external affiliate (partners.postback_url IS NOT NULL), Heftycc fires a GET to that URL on sold-lead with {transaction_id} + {amount} placeholders substituted. Affiliates self-manage this URL via their portal at /partner โ Postback Setup tab.
All revenue accrues to MortgageCo (parent 32) by aggregating across children:
SELECT
(SELECT COUNT(*) FROM hefty.clicks
WHERE offer_id IN (12,13,14,15,16,17,18,19,20,21,22)
AND created_at::date = CURRENT_DATE) AS routed_clicks_today,
(SELECT COUNT(*) FROM hefty.leads
WHERE data->>'brand' = 'mortgageco'
AND created_at::date = CURRENT_DATE) AS leads_today,
(SELECT SUM(price::numeric) FROM hefty.lead_distributions
WHERE accepted = true AND lead_id IN (
SELECT id FROM hefty.leads
WHERE data->>'brand' = 'mortgageco'
AND created_at::date = CURRENT_DATE
)) AS gross_revenue_today,
(SELECT SUM(payout::numeric) FROM hefty.offer_conversions
WHERE offer_id IN (12,13,14,15,16,17,18,19,20,21,22)
AND status = 'approved'
AND created_at::date = CURRENT_DATE) AS net_postback_revenue_today;
Today's snapshot (2026-04-19, captured at write-time, Pacific day):
lead_distributions.priceoffer_conversions.payout yet today (approved postbacks, often hours-delayed)lead_distributions.price = what the buyer committed to pay at accept time (gross, counted immediately).offer_conversions.payout = what the buyer actually paid via postback (net, counted at postback time, often hours/days later).lead_distributions.price is the only revenue source.GREATEST(lead_distributions.price, offer_conversions.payout) per lead so neither path is double-counted or dropped.| aff= | Partner | DB name | Source of clicks |
|---|---|---|---|
| 8 | Meta | fb-mortgageco | Facebook + Instagram ads (primary) |
| 11 | Google โ Try West Capital | google-westcap | Google Ads (THE ONLY Google account) |
| 15 | Google in-house DEPRECATED | google-mortgageco | Historical only (retired 2026-04-19 โ click-ingest aliases aff=15 โ partner_id=11) |
| 4 | Omnisend Email | omnisend-email | Email campaigns |
| 12 | Omnisend SMS | omnisend-sms | Omnisend SMS sends |
| 10 | SimpleTexting DECOMMISSIONED | simpletexting-decommissioned | Historical only (retired 2026-04-19, row kept for attribution) |
| 13 | MobileDrips | mobiledrips | Non-Verizon SMS |
| 14 | Tells.co | tells-co | Push notifications |
| 5 | Organic | organic | Anything untagged (fallback) |
| offer_id | Buyer / Network | Default payout | Model |
|---|---|---|---|
| 12 | AHS Warranty | $15.00 | CPL |
| 13 | ADT Security | $15.00 | CPL |
| 14 | Andersen Windows | $15.00 | CPL |
| 15 | Walk-in Tub | $15.00 | CPL |
| 16 | Quicken Loans | $25.00 | CPA |
| 17 | NAF New American Funding | $25.00 | CPA |
| 18 | Allied Move Quote | $15.00 | CPL |
| 19 | Car Insurance Masters | $15.00 | CPL |
| 20 | Lending Tree Home Equity | $25.00 | CPA |
| 21 | NerdWallet Debt Relief | RevShare | RevShare |
| 22 | Vivint Home Security | $15.00 | CPL |
Admin dashboard view: https://hefty.cc/dashboard โ shows Parent Offer hero card with rolled-up metrics + Child Offers (Buyers) table per this flow.