Goals and revenue

PayPal
PayPal conversion tracking starts after your server captures an order. Send the completed capture returned to the browser.
PayPal revenue tracking
paypal.Buttons({
createOrder: async () => {
const res = await fetch("/api/paypal/orders", { method: "POST" });
return (await res.json()).id;
},
onApprove: async (data) => {
const res = await fetch(`/api/paypal/orders/${data.orderID}/capture`, { method: "POST" });
const order = await res.json();
const capture = order.purchase_units?.[0]?.payments?.captures?.[0];
if (order.status === "COMPLETED" && capture) {
window.stickybeak("purchase", {
revenue: capture.amount.value,
currency: capture.amount.currency_code,
order_id: order.id,
});
}
},
}).render("#paypal-buttons");
PayPal amounts are normal-unit strings such as "49.00"; do not divide them. The order ID prevents duplicates. PayPal return traffic has no referrer, so it cannot steal attribution. Later subscription charges are not recorded.