Conversion postback snippets
Drop-in code for firing conversions from PHP, Node, Shopify, WooCommerce, and Stripe.
Updated 2026-05-21
The network records a conversion only after your backend fires a postback to the edge. Below are minimal snippets you can adapt — each one assumes you've stored the network-issued click_id from the landing page (in a cookie, hidden field, or query string).
Plain PHP
$click_id = $_COOKIE['tofz_click'] ?? null;
if ($click_id) {
$params = http_build_query([
'cid' => 12,
'click_id' => $click_id,
'transaction_id' => $order_id,
'event' => 'purchase',
'payout' => intval($order_total * 100),
'currency' => 'USD',
]);
// Fire and forget — don't block checkout on the network's response.
@file_get_contents("https://edge.trackofferz.com/v1/conv?$params", false,
stream_context_create(['http' => ['timeout' => 2]]));
}
Node / Next.js API route
export async function POST(req: Request) {
const { orderId, total, currency, clickId } = await req.json();
if (!clickId) return new Response('ok'); // organic, nothing to do
const params = new URLSearchParams({
cid: '12',
click_id: clickId,
transaction_id: orderId,
event: 'purchase',
payout: String(Math.round(total * 100)),
currency,
});
// Don't await — checkout shouldn't depend on the network.
void fetch(`https://edge.trackofferz.com/v1/conv?${params}`, {
method: 'GET',
signal: AbortSignal.timeout(2000),
});
return new Response('ok');
}
Shopify (Order Status JavaScript)
In Settings → Checkout → Order status page → Additional scripts:
<script>
var click_id = window.localStorage.getItem('tofz_click');
if (click_id) {
var img = new Image();
img.src =
'https://edge.trackofferz.com/v1/conv?cid=12'
+ '&click_id=' + encodeURIComponent(click_id)
+ '&transaction_id=' + Shopify.checkout.order_id
+ '&event=purchase'
+ '&payout=' + Math.round(Shopify.checkout.total_price * 100)
+ '¤cy=' + Shopify.checkout.currency;
}
</script>
WooCommerce (functions.php)
add_action('woocommerce_thankyou', function($order_id) {
$order = wc_get_order($order_id);
$click_id = WC()->session->get('tofz_click');
if (!$click_id) return;
$params = http_build_query([
'cid' => 12,
'click_id' => $click_id,
'transaction_id' => $order_id,
'event' => 'purchase',
'payout' => intval($order->get_total() * 100),
'currency' => $order->get_currency(),
]);
wp_remote_get("https://edge.trackofferz.com/v1/conv?$params", ['timeout' => 2]);
});
Stripe webhook (recommended for accuracy)
Server-side webhooks are the most reliable trigger. In your payment_intent.succeeded handler:
const click_id = paymentIntent.metadata.tofz_click;
if (click_id) {
const params = new URLSearchParams({
cid: '12',
click_id,
transaction_id: paymentIntent.id,
event: 'purchase',
payout: String(paymentIntent.amount),
currency: paymentIntent.currency.toUpperCase(),
});
await fetch(`https://edge.trackofferz.com/v1/conv?${params}`);
}
The click_id is the network's identifier — not your internal order ID. Capture it on the landing page (it arrives as ?tofz_click=…) and stash it in a cookie, localStorage, or session so it's still around at checkout.