Stripe Affiliate Tracking: Complete Integration Guide | AffiliateBase

Stripe is the leading payment processor for SaaS and membership businesses, handling billions in transactions annually. If you're using Stripe for payments and want to track affiliate conversions accurately, AffiliateBase provides seamless integration through Stripe Connect.

This comprehensive guide will walk you through everything you need to know about setting up affiliate tracking with Stripe, from adding the tracking script to automatic conversion tracking through Stripe webhooks.

Whether you're processing one-time payments, subscriptions, or both, AffiliateBase's Stripe integration ensures every conversion is tracked accurately.

Follow these steps to set up Stripe affiliate tracking:

1

Add the Tracking Script

Add the AffiliateBase tracking script to your website. This captures the referral ID when visitors arrive via affiliate links. Using jsDelivr CDN ensures fast global delivery and automatic updates. No hosting required.
html
<script>(function(w,r){w._abq=w._abq||[];w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)}})(window,'affiliatebase');</script>
<script async src="https://cdn.jsdelivr.net/npm/affiliatebase-tracking@1/src/index.js" data-org-id='YOUR_ORG_ID'></script>
2

Connect Your Stripe Account

Pass the referral ID as client_reference_id to Stripe for accurate conversion tracking. In your AffiliateBase dashboard, go to **Settings > Integrations > Stripe** and connect your Stripe account. This enables automatic conversion tracking via Stripe webhooks.
3

Stripe Payment Links (Easiest)

If you use Stripe Payment Links or Buy Buttons, add this script to automatically pass the referral ID to Stripe.
html
<!-- Add to your site alongside the tracking script -->
<script>
  document.addEventListener('DOMContentLoaded', function() {
    setTimeout(function() {
      const referralId = window.affiliatebase_referral || '';
      if (!referralId) return;

      // Update Stripe Payment Links
      document.querySelectorAll('a[href^="https://buy.stripe.com/"]').forEach(link => {
        const url = new URL(link.href);
        if (!url.searchParams.has('client_reference_id')) {
          url.searchParams.set('client_reference_id', referralId);
          link.href = url.toString();
        }
      });

      // Update Stripe Pricing Tables
      document.querySelectorAll('stripe-pricing-table').forEach(table => {
        table.setAttribute('client-reference-id', referralId);
      });

      // Update Stripe Buy Buttons
      document.querySelectorAll('stripe-buy-button').forEach(button => {
        button.setAttribute('client-reference-id', referralId);
      });
    }, 1500);
  });
</script>
4

Stripe Checkout (Custom Integration)

If you use Stripe Checkout programmatically, pass the referral ID as the client_reference_id.
javascript
// Get referral ID from tracking script
const referralId = window.affiliatebase_referral || '';

const session = await stripe.checkout.sessions.create({
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
  customer_creation: 'always',
  ...(referralId && { client_reference_id: referralId }),
  line_items: [
    { price: 'price_xxx', quantity: 1 },
  ],
  mode: 'subscription',
});
5

Test Your Integration

Visit your site with a test affiliate link, then make a test purchase to verify tracking.
javascript
// Visit your site with a test affiliate link:
// https://yoursite.com?via=test123

// Check the console to verify the referral ID is captured:
console.log(window.affiliatebase_referral); // Should show "test123"

// Make a test purchase and verify in your AffiliateBase dashboard

Why Use AffiliateBase for Stripe Tracking?

AffiliateBase provides the most reliable and comprehensive Stripe affiliate tracking solution for SaaS and membership businesses.

One-Click Stripe Connect

Connect your Stripe account in seconds with Stripe Connect. No manual webhook configuration required.

Server-Side Tracking

Track conversions via Stripe webhooks on the server, ensuring accuracy even when ad blockers are present.

Subscription Lifecycle Tracking

Automatically track subscription renewals, upgrades, and downgrades. Get accurate attribution for recurring revenue.

Real-Time Processing

Process Stripe webhooks in real-time for instant conversion tracking and commission attribution.

Payment Links Support

Works seamlessly with Stripe Payment Links, Buy Buttons, and Pricing Tables.

Handles All Payment Types

Track one-time payments, subscriptions, setup fees, and usage-based billing.

Frequently Asked Questions

How does Stripe affiliate tracking work?
AffiliateBase uses Stripe Connect and webhooks to receive payment events in real-time. When a customer completes a payment, Stripe sends a webhook to AffiliateBase, which then attributes the conversion to the correct affiliate.
Do I need to manually configure webhooks?
No! When you connect your Stripe account via Stripe Connect, AffiliateBase automatically sets up the necessary webhooks for you.
Does it work with Stripe Payment Links?
Yes! Add the Payment Links script to your site and referral IDs are automatically passed to Stripe via the client_reference_id parameter.
How are subscription renewals tracked?
AffiliateBase automatically tracks subscription renewals through Stripe webhooks. Each renewal is attributed to the original affiliate.
What happens when a customer upgrades or downgrades?
AffiliateBase tracks subscription changes automatically. Commissions are calculated based on the new subscription amount.
Is server-side tracking more reliable than client-side?
Yes! Server-side tracking via webhooks can't be blocked by ad blockers and doesn't rely on cookies, ensuring 100% accuracy.
What tracking parameters does AffiliateBase support?
AffiliateBase automatically detects ?via=, ?ref=, ?affiliate=, and ?a= URL parameters.

Ready to Set Up Stripe Affiliate Tracking?

Get started with AffiliateBase today and start tracking Stripe conversions accurately with server-side webhooks.