Skip to main content
All CollectionsIntegrationsAvailable Integrations
Stripe Integration via Payment Links
Stripe Integration via Payment Links
David Rolenc avatar
Written by David Rolenc
Updated over a month ago

Integrating Stripe via payment links is a quick way to set up your affiliate program for your landing pages. After setup, Trackdesk automatically tracks all conversions from your customers. Conversions are automatically updated for billing events, refunds, and cancellations.

Stripe payment link can be identified by link “buy.stripe.com." present on a page.

Integration steps

  1. Install Trackdesk app
    Our Stripe app is available here in the Stripe marketplace - https://marketplace.stripe.com/apps/trackdesk

  2. Fill in all necessary information in the settings of the Stripe app and save changes.

    1. Tenant ID - Your Tenant ID can be found at the bottom of the Settings page

    2. Personal token - Personal tokens can be found at the bottom of the Settings page, or a new one can be created via the Personal tokens menu in the Settings

  3. Set up tracking of clicks
    Track clicks by including the following code on every page of your website where you want to track clicks, including all landing pages added to this offer. For best results, position the code as high as possible within the <head> tag of your HTML document.

    <!-- Trackdesk tracker begin -->
    <script async src="//cdn.trackdesk.com/tracking.js"></script> <script>
    (function(t,d,k){(t[k]=t[k]||[]).push(d);t[d]=t[d]||t[k].f||function(){(t[d].q=t[d].q||[]).push(arguments)}})(window,"trackdesk","TrackdeskObject");

    trackdesk('YOUR TENANT ID', 'click');
    </script>
    <!-- Trackdesk tracker end -->

    Make sure to replace YOUR TENANT ID with your actual tenant ID.

  4. Set up the addition of CID to payment links.

    Add the following snippet to all pages where payment links are located. Add the snippet ideally at the end of the <body> tag.

    <!-- Trackdesk set client_reference_id help fuction begin -->
    <script>
    (function () {
    var cookie = document.cookie.match('(^|;)\\s*trakdesk_cid\\s*=\\s*([^;]+)');
    if (Array.isArray(cookie)) {
    try {
    var trakdeskCid = JSON.parse(cookie.pop());
    var cid = trakdeskCid['cid'];
    document.querySelectorAll('a[href^="https://buy.stripe.com/"]').forEach(function (a) {
    var url = new URL(a.href);
    url.searchParams.set('client_reference_id', cid);
    a.href = url.href;
    });
    } catch (e) {
    console.log(e);
    }
    }
    })();
    </script>
    <!-- Trackdesk set client_reference_id help fuction end -->


    The above code is to be used when payment link is on a different page than the landing page.

    Note: that the abbreviation in the name of the cookie "trakdesk_cid" is on purpose.

Below is the script to use when the payment link is on the same page as the landing page.

  <!-- Trackdesk set client_reference_id help fuction, click script on same page as help script begin -->
<script>
(function () {
var linksUpdated = false;
setInterval(function () {
var cookie = document.cookie.match('(^|;)\\s*trakdesk_cid\\s*=\\s*([^;]+)');
if (Array.isArray(cookie) && !linksUpdated) {
try {
var trakdeskCid = JSON.parse(cookie.pop());
var cid = trakdeskCid['cid'];
document.querySelectorAll('a[href^="https://buy.stripe.com/"]').forEach(function (a) {
var url = new URL(a.href);
url.searchParams.set('client_reference_id', cid);
a.href = url.href;
});
} catch (e) {
console.log(e);
} finally {
linksUpdated = true;
}
}
}, 300)
})();
</script>
<!-- Trackdesk set client_reference_id help fuction, click script on same page as help script end -->

Payment link on the same page as Landing page + AUTOMATIC addition of Stripe promo code

This is used in cases where tenant wants to automatically give a discount for users if they used an affiliate tracking link. This code adds CID same as the above help scripts for Stripe payment links and on top it adds a prefill for a promo code.

One thing to note, in order for this to work, you need to allow the Payment link to accept promo codes (in settings of the Stripe payment link).

<!-- Trackdesk set client_reference_id help fuction, click script on same page as help script begin -->

<script>

(function () {

var linksUpdated = false;

setInterval(function () {

var cookie = document.cookie.match('(^|;)\\s*trakdesk_cid\\s*=\\s*([^;]+)');

if (Array.isArray(cookie) && !linksUpdated) {

try {

var trakdeskCid = JSON.parse(cookie.pop());

var cid = trakdeskCid['cid'];

document.querySelectorAll('a[href^="https://buy.stripe.com/"]').forEach(function (a) {

var url = new URL(a.href);

url.searchParams.set('client_reference_id', cid);

url.searchParams.set('prefilled_promo_code', 'REPLACE_WITH_STRIPE_DISCOUNT_CODE');

a.href = url.href;

});

} catch (e) {

console.log(e);

} finally {

linksUpdated = true;

}

}

}, 300)

})();

</script>

<!-- Trackdesk set client_reference_id help fuction, click script on same page as help script end -->

Testing Your Integration

Note that our Stripe app works only for Stripe live mode (not for Stripe test mode).

Note that our Stripe app automatically checks for new conversions once an hour. In order to speed this up, you can do a manual check in the settings of our Stripe app by using the Check Now button.

Please remember to test the creation of click and conversion before starting your program. This way, you can verify that tracking has been set up correctly. You can create a test click and conversion by following the steps described here.

If any tracking issues occur, you can go through these Stripe integration troubleshooting steps described here.

Did this answer your question?