How to Track Affiliate Revenue with Stripe and Blossu

Connect your Stripe account to Blossu to automatically track conversions, attribute sales to the right partners, and calculate commissions.

Image: Stripe + Blossu integration overview

Step 1: Connect Stripe

Before you can track revenue, you need to connect your Stripe account to Blossu. This allows us to receive webhook events when payments are made.

1

Go to the Setup wizard

In your Blossu dashboard, go to the Setup page and navigate to the "Attribute revenue" step.

2

Click Connect Stripe

Click the "Connect" button next to Stripe. You'll be redirected to Stripe to authorize the connection.

Image: Connect Stripe button in setup wizard
3

Authorize the connection

On Stripe, select the account you want to connect and click "Connect". You'll be redirected back to Blossu automatically.

Step 2: Choose your integration approach

How you pass the referral ID to Stripe depends on how you've integrated Stripe into your product. Choose the approach that matches your setup:

Server-side integrations

Use this if you create Checkout Sessions on your server, use custom payment forms, or want to track promo codes.

  • Stripe Checkout Sessions
  • Custom payment forms
  • Promo codes

Client (Website)

Use this if you use Stripe.js on the frontend, or Stripe's no-code tools like Payment Links, Buy Buttons, or Pricing Tables.

  • Stripe.js Checkout
  • Payment Links
  • Buy Buttons
  • Pricing Tables

Option A: Server-side integrations

If you create Checkout Sessions on your server, you need to pass the referral ID from the client to your server, then include it in the session creation.

1

Capture the referral ID on the client

When the Blossu tracking script detects a referral, it stores the referral ID in window.blossu_ref_id. You need to pass this to your server when creating a checkout.

JavaScript
// Get the referral ID from the Blossu script
const referralId = window.blossu_ref_id || null;

// Pass it to your checkout endpoint
fetch('/api/create-checkout', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    priceId: 'price_xxx',
    referralId: referralId,
  }),
});
2

Include client_reference_id in the Checkout Session

On your server, include the referral ID as the client_reference_id when creating the Checkout Session. This is how Blossu knows which partner referred the sale.

JavaScript
const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  line_items: [{ price: req.body.priceId, quantity: 1 }],
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
  client_reference_id: req.body.referralId, // The Blossu referral ID
});
Image: Diagram showing client to server to Stripe flow
3

Alternative: Use metadata

If you're using custom payment forms instead of Checkout Sessions, you can store the referral ID in the customer or subscription metadata:

JavaScript
const customer = await stripe.customers.create({
  email: req.body.email,
  metadata: {
    blossu_ref_id: req.body.referralId,
  },
});

const subscription = await stripe.subscriptions.create({
  customer: customer.id,
  items: [{ price: 'price_xxx' }],
  metadata: {
    blossu_ref_id: req.body.referralId,
  },
});

Option B: Client (Website)

Use this option if you integrate with Stripe on the client side, either using Stripe.js or Stripe's no-code embeds like Payment Links, Buy Buttons, or Pricing Tables.

1

Payment Links

Add data-blossu to any link that points to a Stripe Payment Link. The Blossu script will automatically append the referral ID when the link is clicked.

HTML
<a href="https://buy.stripe.com/YOUR_PAYMENT_LINK" data-blossu>
  Subscribe Now
</a>
2

Buy Buttons

Add data-blossu to your stripe-buy-button element:

HTML
<stripe-buy-button
  data-blossu
  buy-button-id="buy_btn_xxx"
  publishable-key="pk_live_xxx"
></stripe-buy-button>
3

Pricing Tables

Add data-blossu to your stripe-pricing-table element:

HTML
<stripe-pricing-table
  data-blossu
  pricing-table-id="prctbl_xxx"
  publishable-key="pk_live_xxx"
></stripe-pricing-table>
Image: Example of Stripe Pricing Table with data-blossu

How attribution works

Here's what happens when a referred customer makes a purchase:

  1. Visitor arrives via referral link - The Blossu tracking script captures the partner's code and stores it as blossu_ref_id.

  2. Customer starts checkout - The referral ID is passed to Stripe via client_reference_id or metadata.

  3. Payment completes - Stripe sends a webhook to Blossu with the payment details and referral ID.

  4. Blossu attributes the sale - We match the referral ID to the partner and calculate their commission.

Image: Full attribution flow diagram

Recurring payments

For subscription businesses, Blossu automatically tracks all recurring payments. When a customer renews, we attribute the revenue to the original referring partner based on the stored referral ID.

Testing your integration

To test your integration:

  1. Visit your site with a test referral link (e.g., yoursite.com?via=test)

  2. Complete a test purchase using Stripe's test card (4242 4242 4242 4242)

  3. Check your Blossu dashboard - you should see the conversion attributed to the test partner