The sale arrives without the click
The sale webhook only carries the origin if the click id was taken all the way to checkout. Free-text parameters get mixed with real ids.
Middleware that connects the checkout, RedTrack and Meta. Every sale becomes a conversion attributed to the right click, exactly once, even with duplicated or out-of-order webhooks or a destination that is down.
LAB environment running 24/7 · flow validated end to end with real test purchases
The sales platform knows someone bought. The tracker knows which ad the click came from. Without a reliable bridge between them, campaign optimization runs on wrong data.
The sale webhook only carries the origin if the click id was taken all the way to checkout. Free-text parameters get mixed with real ids.
Redeliveries and refunds before approval happen. Counting twice or losing an event distorts revenue and attribution.
A subscription renewal is revenue, but not a new sale for the ad. Order bump, upsell, refund and chargeback each need their own handling.
From the ad click to the conversion event on Meta. Each color is a platform; steps marked "This project" are own code.
The RedTrack tracking domain records the click and generates a 24-character click id.
Own script reads the click id (query and cookies), fires InitiateCheckout and video milestones (play, 1, 3, 5 and 10 min) with deduplication. A network failure never blocks the checkout.
The click id travels in the checkout platform origin parameters up to the purchase. Hotmart is the integration in use today.
Token compared in constant time, schema validated with Zod, personal data redacted, event classified and stored idempotently. The response is sent before any external call.
Conversion sent to RedTrack with value, type and transaction id. Timeout, 429 and 5xx go to retry with exponential backoff. 4xx errors are not retried.
RedTrack forwards the event to Meta. Purchase, order bump and upsell go out as distinct events, with the transaction id as the deduplication key.
Event id as primary key and a unique transaction + event pair. Duplicates go to their own table. Redelivery of a failed event retries the send without creating a new row.
Purchase, order bump, upsell, downsell, renewal, refund, chargeback, cancellation, overdue and unknown. A renewal counts as revenue and is not sent as a new conversion.
When recurrence data is missing, the backend queries the platform payments API after answering the webhook. The merge only fills empty fields, divergence becomes a conflict for review.
CRUD with optimistic locking, an append-only audit trail and an in-memory snapshot that fails closed on boot. Rollback by feature flag, no destructive migration.
An event already sent is never resent or reclassified automatically. A mapping change after the send becomes a visible conflict in the panel, with a preview before reprocessing.
Gross, refunds, chargebacks and net computed from events. When history is incomplete, net stays null instead of an invented zero.
Session with HttpOnly cookie and CSRF token, rate limit on login and admin, strict CSP, opaque 404 and a panel that stays closed in production without a token. Responses and logs carry no personal data.
Health and readiness, duplicate and retry counters, alerts for backlog, failure rate and missing webhooks. Additive, idempotent migrations and deploys gated by tests.
Interface in HTML, CSS and ES modules served by the backend itself, no framework and no bundler. The screens below use synthetic data.

The checkout platform is the financial truth, the database is the operational truth, RedTrack owns attribution and Meta only optimization.
The volume does not justify it. Retry and enrichment run in the same process, on a single instance. The limit of this choice is documented.
The page click receives engagement events. The checkout click receives the purchase. Keeping them apart avoids attributing a sale to the wrong event.
The backend does not call the Conversions API directly. A single delivery path lowers the risk of duplicated events on Meta.
The panel can ask a model for a mapping suggestion for an unknown offer. The suggestion never writes anything. Delivery stays deterministic.
The repository is private. I can walk through the architecture and the code in a call.
Independent project. Not affiliated with or endorsed by RedTrack, Hotmart or Meta. Names and trademarks belong to their owners.