Stripe checkout custom integration (Stripe via API)
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_cid" cookie 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 your landing pages.
Stripe API Access: Access to your Stripe backend code where
checkout_sessionsare created.
2, 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. Your backend can read this cookie and pass it to Stripe.
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("YOUR_TENANT_ID", "click", {}, (data) => {
// Use data.cid to pass the ID to your checkout process
console.log("Trackdesk CID:", data.cid);
});
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.
