API Integration for Ecommerce Affiliate Programs: Simplifying Success with Trackli
Why Ecommerce Affiliate Tracking Is Different
SaaS affiliate programs track a relatively simple event: a customer signs up and starts paying. Ecommerce is more complex — customers buy multiple items at different price points, return products, and sometimes place orders that get cancelled. Your affiliate tracking needs to handle this variable reality.
Webhook Integration: The Foundation
The cleanest way to track ecommerce affiliate sales is through your payment or order management platform's webhooks. When a Shopify order is completed or a Stripe payment succeeds, a webhook fires instantly. Trackli receives that webhook, matches the order to an affiliate via the customer's ref code, and records the commission automatically.
This approach captures the actual purchase event — not a form submission or a page view — which means your commission data reflects real revenue.
Passing the Ref Code Through Checkout
The critical integration step is ensuring the affiliate's ref code travels from the referral link click through to the completed order. The recommended approach:
- Affiliate shares a link:
yourstore.com?ref=affiliatecode - Your store saves the ref code to the customer's session
- At checkout, the ref code is included in the order metadata (Stripe metadata, Shopify order attributes, etc.)
- Trackli reads the ref code from the webhook payload and attributes the commission
The Trackli REST API for Custom Flows
If your checkout is custom-built or uses a platform Trackli doesn't have a native webhook for, the REST API handles the integration. A single POST to /api/conversion with the order amount, currency, and ref code records the conversion programmatically:
POST /api/conversion
X-API-Key: your_api_key
Body: { "affiliateRefCode": "casey", "orderAmount": 4900, "currency": "usd" }
Variable Commission Structures
Ecommerce affiliate programs often use percentage-based commissions (e.g., 10% of order value) rather than flat fees. Trackli supports both, and commissions are calculated automatically based on the order amount from the webhook — no manual computation required.
Ready to Integrate?
Connect your Shopify store or payment platform webhook to Trackli and have affiliate tracking live within the hour. Read the integration documentation →