Integration
Integrate our tracking script into your website to start tracking affiliate sales.
Conversion Tracking Script
Place this script in the <head> of your website, and call the trackConversion function on your order confirmation page.
<script src="https://flow-app.apphosting.dev/tracking.js" async defer></script>
<script>
window.flow = window.flow || function() {
(window.flow.q = window.flow.q || []).push(arguments);
};
flow('init', 'YOUR_BRAND_ID');
// --- Example: Track a conversion after a successful purchase ---
// This should be triggered on your order confirmation page.
// The product ID must match the ID of a product you've created in the Flow dashboard.
function trackConversion(productId, orderId, orderTotal, customerEmail) {
flow('track', 'conversion', {
productId: productId, // REQUIRED: The ID of the product from Flow
orderId: orderId, // REQUIRED: Your internal order ID
orderTotal: orderTotal, // REQUIRED: The total value of the sale
customerEmail: customerEmail // Optional: The customer's email
});
}
// Example usage:
// trackConversion('product1', 'ORDER-12345', 99.99, 'customer@example.com');
</script>
API Reference (sendBeacon)
Our tracking script uses navigator.sendBeacon to reliably report conversions. This is the underlying method used.
// This endpoint is designed for public, client-side use with navigator.sendBeacon.
// For server-to-server tracking, you would need a protected endpoint with an API key.
// The tracking.js script handles this automatically. This is for reference.
const payload = {
affiliateId: 'AFFILIATE_ID_FROM_BROWSER_STORAGE',
productId: 'YOUR_PRODUCT_ID',
orderId: 'ORDER_12345',
orderTotal: 99.99,
customerEmail: 'customer@example.com'
};
// Use sendBeacon for reliable, asynchronous tracking.
navigator.sendBeacon('https://flow-app.apphosting.dev/api/sales', JSON.stringify(payload));