Skip to main content

Install Tracking Script

Install the tracking script and enable referral attribution

Table of Contents

Install Tracking Script

Use the script from setup step 4.

<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/@relay-capital/[email protected]/dist/track.min.js"
  data-account-id="YOUR_ACCOUNT_ID">
</script>

Replace YOUR_ACCOUNT_ID with your account ID.

Add Stripe Checkout Attribution

Most Stripe setups only need one extra attribute after the script is installed.

Use this path if your site links to a Stripe Payment Link:

<a href="https://buy.stripe.com/your_payment_link" data-affiliatebase>Buy now</a>

Buy Button or Pricing Table

Use the same attribute on Stripe-hosted elements:

<stripe-buy-button buy-button-id="buy_btn_xxx" publishable-key="pk_live_xxx" data-affiliatebase></stripe-buy-button>

<stripe-pricing-table
  pricing-table-id="prctbl_xxx"
  publishable-key="pk_live_xxx"
  data-affiliatebase
></stripe-pricing-table>

Backend-created Checkout Sessions

If your server creates Checkout Sessions, submit the referral ID to your server first:

<form action="/checkout" method="post" data-affiliatebase data-affiliatebase-param-name="referral_id">
  <button type="submit">Start checkout</button>
</form>

Then set client_reference_id server-side when creating the Stripe Checkout Session.

Canonical Attribution Parameter

The tracking flow is built around ?via=TOKEN.

Example: https://yoursite.com/pricing?via=abc123

Key Runtime Values

  • window.AffiliateBase.referral
  • window.affiliatebase_referral

Browser state is only available in the visitor’s browser. Server-side Stripe code cannot read window.AffiliateBase unless the page submits the referral value first.

Conversion Tracking

When conversion is complete:

affiliatebase('convert', { email: '[email protected]' });

Next steps