Stripe Payment Links Integration

Automatic affiliate tracking with Stripe Payment Links

Table of Contents

Stripe Payment Links Integration

Stripe Payment Links let you accept payments without writing code. AffiliateBase automatically tracks conversions from Payment Links, Pricing Tables, and Buy Buttons.

How It Works

When you add the AffiliateBase tracking script to your page:

  1. Script detects Stripe Payment Links, Pricing Tables, and Buy Buttons
  2. Automatically appends client_reference_id with the referral ID
  3. Conversions are tracked without any code changes

Setup

Step 1: Add the Tracking Script

Add to any page containing Stripe Payment Links:

<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>

No changes needed to your Payment Links. Just add them normally:

<!-- Stripe Payment Link Button -->
<a href="https://buy.stripe.com/xxxxx">Buy Now</a>

The tracking script automatically modifies Payment Link URLs to include the referral ID.

Supported Stripe Elements

Standard Payment Link buttons work automatically:

<a href="https://buy.stripe.com/xxxxx" class="your-button-styles">
  Get Started - $29/month
</a>

Pricing Tables

Stripe Pricing Tables are automatically enhanced:

<script async src="https://js.stripe.com/v3/pricing-table.js"></script>
<stripe-pricing-table
  pricing-table-id="prctbl_xxxxx"
  publishable-key="pk_live_xxxxx">
</stripe-pricing-table>

The script adds client-reference-id to the pricing table.

Buy Buttons

Stripe Buy Buttons also work automatically:

<script async src="https://js.stripe.com/v3/buy-button.js"></script>
<stripe-buy-button
  buy-button-id="buy_btn_xxxxx"
  publishable-key="pk_live_xxxxx">
</stripe-buy-button>

Testing

Verify Script Enhancement

  1. Open browser Developer Tools
  2. Click an affiliate link to your page (e.g., ?via=test)
  3. Inspect a Payment Link element
  4. Check that client_reference_id was appended to the URL

Test a Purchase

  1. Visit your page via an affiliate link
  2. Click a Payment Link
  3. Complete checkout with test card 4242 4242 4242 4242
  4. Verify conversion appears in AffiliateBase dashboard

No-Code Platforms

Webflow

  1. Add the tracking script to your site’s Custom Code (head)
  2. Add Stripe Payment Links using embed blocks
  3. Tracking works automatically

Squarespace

  1. Add the tracking script via Code Injection (header)
  2. Use Code Blocks to embed Payment Links
  3. No additional configuration needed

WordPress

  1. Add tracking script to header (via theme or plugin)
  2. Embed Payment Links in posts or pages
  3. Automatic tracking enabled

Multiple Payment Options

If your page has multiple payment options, all are tracked:

<!-- All of these work automatically -->
<a href="https://buy.stripe.com/monthly">Monthly - $29</a>
<a href="https://buy.stripe.com/annual">Annual - $290</a>

<stripe-pricing-table pricing-table-id="prctbl_xxxxx">
</stripe-pricing-table>

<stripe-buy-button buy-button-id="buy_btn_xxxxx">
</stripe-buy-button>

Limitations

Referral Required

The script only adds tracking when a valid referral exists. If a visitor arrives without an affiliate link, no client_reference_id is added.

Payment Links on external domains (not your site) won’t be tracked. The tracking script must be on the same page as the Payment Link.

JavaScript Required

Automatic enhancement requires JavaScript. Users with JavaScript disabled will see unmodified Payment Links.

Combining with Checkout Sessions

You can use both Payment Links and Checkout Sessions:

  • Payment Links: Simple purchases, no-code setup
  • Checkout Sessions: Custom flows, complex products

Both track conversions the same way through the client_reference_id.

Troubleshooting

  1. Check tracking script is loading (look for console logs)
  2. Verify a referral was captured (window.affiliatebase_referral)
  3. Ensure Payment Link is a valid buy.stripe.com URL

Conversion Not Attributed

  1. Verify referral existed before clicking Payment Link
  2. Check Stripe webhook delivery in Stripe Dashboard
  3. Ensure AffiliateBase webhook endpoint is active

Pricing Table Not Enhanced

  1. Ensure tracking script loads before Stripe’s pricing-table.js
  2. Check for JavaScript errors in console
  3. Try refreshing the page with an affiliate parameter

Next Steps