When a customer starts a subscription with an affiliate's coupon, redeem the coupon once to get a Click ID (CID), save it, and send it with every charge. Each recurring payment is then attributed to that affiliate.
How it works
When the customer applies the coupon, your server calls the coupon redeem endpoint. Trackdesk finds the affiliate who owns the coupon and returns a CID. No conversion is created at this point.
Save the CID with the customer or subscription record.
On the first charge and on every renewal, create a conversion with that CID.
Setup
Step 1: Redeem the coupon
Send this request when the customer applies the coupon:
POST https://TENANT_ID.trackdesk.com/tracking/coupon/v1/redeem
{
"couponCodes": ["COUPON_CODE"],
"revenueOriginId": "REVENUE_ORIGIN_ID"
}
Replace these values:
TENANT_ID: your Tenant IDCOUPON_CODE: the code the customer entered. You can send up to 50 codes; the first one that matches an affiliate's coupon is usedREVENUE_ORIGIN_ID: your Revenue Origin ID
To store extra affiliate data, you can also send customParams with affS1 to affS5.
The response looks like this:
{
"cid": "b1f3c5a7-9d2e-4a8b-bc11-7c2e0a9f4d6e",
"expiredAt": "2027-04-19T12:00:00Z",
"conversionAttributionType": "CONVERSION_ATTRIBUTION_TYPE_LAST_TOUCH"
}Save cid with the customer's subscription; you can ignore the other fields.
Step 2: Create a conversion for each charge
On the first payment and on every renewal, send:
POST https://TENANT_ID.trackdesk.com/tracking/conversion/v1
{
"cid": "CLICK_ID",
"conversionTypeCode": "CONVERSION_TYPE",
"amount": { "value": "AMOUNT" },
"externalId": "EXTERNAL_ID"
}
Replace these values:
CLICK_ID: thecidyou saved in Step 1CONVERSION_TYPE: the code of your Conversion Type, for examplesaleAMOUNT: the charge amount as a string, for example"100.50"EXTERNAL_ID: a unique ID for this charge, such as the invoice ID, so the same charge is never recorded twice
You can also send customerId and customParams.advS1 to customParams.advS5.
Testing
Make sure the coupon exists in Trackdesk and is assigned to an affiliate.
Open your site without tracking parameters, apply the coupon and check that the redeem call returns a
cid.Complete a test payment. A conversion appears in the Conversion report, attributed to the coupon's affiliate.
