Integrate your custom-developed Stripe Checkout with Trackdesk to automate affiliate tracking. This guide is designed for developers and explains how to pass the Trackdesk Click ID (CID) to Stripe via the API to ensure conversions are attributed correctly.
⚠️ Important:
Manual data handling: Unlike the standard Stripe app, this custom integration requires your developer to manually capture and pass the
client_reference_idto Stripe's Checkout Session API.Cookie persistence: Ensure your website's domain matches where the Trackdesk click script is running to allow the
trakdesk_cidcookie to be read accurately.
Before you start
Before beginning the integration, ensure you have the following:
Click script installed: The standard Trackdesk click tracking script must be active on every page of your website, including all landing pages, placed as high as possible in the
<head>.Stripe API access: Access to your Stripe backend code where
checkout_sessionsare created.
Set up the Trackdesk Stripe app
Install the Trackdesk app from the Stripe Marketplace.
In the app's settings, enter your Tenant ID and a personal token, then save.
Both are under Your Trackdesk identifiers at the top right of any Settings page. You can create a new token in Settings → Integrations → Personal tokens.
Step-by-step instructions
The goal of this integration is to send the Trackdesk CID (Click ID) into the Stripe client_reference_id parameter when creating a checkout session. For more technical details, refer to the Stripe Documentation.
Step 1: Retrieve the Trackdesk CID
There are two primary methods to retrieve the unique Click ID assigned to a visitor. Choose the one that best fits your technical architecture:
Option A: Retrieve via cookie (server-side)
When a user visits your site via an affiliate link, Trackdesk stores their ID in a cookie named trakdesk_cid. The cookie value is a small JSON object, so your backend parses it and passes its cid field to Stripe, not the whole value.
Option B: Retrieve via callback (client-side)
You can modify your existing Trackdesk click script to include a callback function. This function triggers as soon as the CID is generated, allowing you to store it in a variable or hidden form field.
// Example of the callback function in the click script
trackdesk("TENANT_ID", "click", {}, (data) => {
// Use data.cid to pass the ID to your checkout process
console.log("Trackdesk CID:", data.cid);
});
Replace TENANT_ID with your Tenant ID.
Step 2: Pass the CID to Stripe
When creating a Checkout Session via the Stripe API, map the Trackdesk CID to the client_reference_id parameter. Stripe keeps client_reference_id on the session, and the Trackdesk Stripe app uses it to attribute the payment to the affiliate.
Testing your integration
Before officially launching your affiliate program, we highly recommend running a test click and conversion to verify everything is set up correctly. For the steps, see Testing an Offer.
⚠️ Important: When testing, note the following:
Our Stripe app works across all Stripe environments: Live mode, Test mode, and Sandbox mode.
Our Stripe app checks for new conversions every 15 minutes. To speed this up during testing, go to the Trackdesk Stripe app settings in your Stripe Dashboard and click the Check Now button to force a manual sync.
If you run into any tracking issues, see our Stripe Integration Troubleshooting guide.
