Server-side conversion tracking for Next.js and Node.js stores
Headless and custom storefronts know the order for sure on the server. One call sends it to every ad platform, with the browser's ad click, GA ids and visitor id read from the request's cookies.
Illustration of the event flow
What you get
One call per order
trakero.purchase({ orderId, value, currency, items, customer, shopper }) sends event purchase_{orderId}, the same id the browser SDK uses.
shopperFromRequest(req)
Reads IP, user agent and the first-party cookies (fbc, fbp, ttclid/_ttp, _scid, _epik, GA client and session) from any Fetch API request.
Safe retries
429, 5xx and network errors retry with backoff and an idempotency key, so a retry is never a second purchase.
Typed and small
TypeScript types, ESM, no dependencies, Node 18+, Edge runtimes with fetch.
Where browser-only tracking loses the sale
Pick a situation your shoppers are in and watch one order take both paths.
A shopper from your Facebook ad places an order.
Illustration of what happens on shoppers' devices, not a measurement.
Set up in minutes
- 1Add the browser snippet to your layout so the first-party cookies exist.
- 2Create a secret key in Developers and set TRAKERO_SECRET_KEY on the server.
- 3Call trakero.purchase(...) where the order is created, passing shopperFromRequest(req).
- 4Call refund and cancel from your order lifecycle.
Questions
How do I install it?+
The package is @trakero/node. Until the public npm release, install it from the Trakero repository (sdk/node).
Does it work in the Edge runtime?+
Yes. It only needs fetch and AbortController.