Background
⌘K

Stripe Payment Links

Learn how to add affiliate tracking to your Stripe Payment Links for proper commission attribution.

Silvestro
Written by Silvestro
Updated more than a month ago

Stripe Payment Links Integration

💡 Make sure your Stripe account is connected.

If you're using Stripe Payment Links (URLs starting with buy.stripe.com), add this enhancement script to automatically include referral tracking.

Installation

Add this script to your website's <head> section, right after your Affonso tracking script:

<!-- Your existing Affonso tracking script -->
<script
  async
  defer
  src="https://affonso.io/js/pixel.min.js"
  data-affonso="YOUR_PUBLIC_PROGRAM_ID"
  data-cookie_duration="YOUR_COOKIE_DURATION"
></script>

<!-- Add this enhancement script right after -->
<script>
  function enhanceStripeLinks() {
    if (window.affonso_referral) {
      document.querySelectorAll('a[href*="buy.stripe.com"]').forEach((link) => {
        if (link.href.includes('client_reference_id=')) return;
        const separator = link.href.includes('?') ? '&' : '?';
        link.href =
          link.href +
          separator +
          'client_reference_id=' +
          window.affonso_referral;
      });
    }
  }

  setTimeout(enhanceStripeLinks, 800);
  setTimeout(enhanceStripeLinks, 1500);
  setTimeout(enhanceStripeLinks, 2500);
  window.addEventListener('affonso_referral_ready', enhanceStripeLinks);
</script>

How It Works

  1. Visitor clicks affiliate link → Affonso sets tracking cookie
  2. Enhancement script runs → Finds all Payment Links on your page
  3. Adds referral tracking → Appends client_reference_id to each link
  4. Customer purchases → Stripe receives tracking data → Affiliate gets credited

Testing

  1. Visit your site with ?atp=test (our test affiliate parameter)
  2. Check browser DevTools → ApplicationCookies → look for affonso_referral
  3. Inspect your Payment Links - URLs should now include client_reference_id=
  4. Make a test purchase to verify tracking in your Affonso dashboard

Note: Use 100% discount codes for live testing without payments - Stripe test mode won't appear in Affonso.

Was this article helpful?

If you still need help, our support team is here for you.

Contact Support
bg

Ready to Scale Your SaaS?

Affonso is the easiest way to launch your own affiliate program. We take care of the technical stuff, so you can focus on growing your business.