How to Set Up BTCPay Server Referral and Affiliate Tracking

Last updated March 5, 2026

If you use Oshi's referral or affiliate programs with BTCPay Server, you need to make sure referral tracking carries through from the initial link click all the way to the BTCPay invoice. Without this, Oshi can't attribute purchases to the referrer and commissions won't be issued.

How It Works

When a customer clicks a referral or affiliate link, they land on your website with referral and tracking parameters in the URL. Your site needs to:

  1. Capture those parameters when the customer lands
  2. Store them (via cookies or local storage) so they persist as the customer browses
  3. Include them in the BTCPay invoice metadata when the customer checks out

Implementation

Capture and Store Referral Parameters

When a customer lands on your site from a referral link, extract all URL parameters (e.g., ref, utm_source, campaign, ttl, etc.) and store them. Use cookies or local storage so the values persist if the customer navigates to other pages before checking out.

Include Parameters in Invoice Metadata

When creating the BTCPay invoice at checkout, pass the stored referral values in the metadata:

{
  "metadata": {
    "email": "customer@example.com",
    "ref": "pvHefU",
    "utm_source": "oshi",
    "buyerAcceptsMarketing": true
  }
}

When Oshi receives this invoice, it matches the ref value to the referrer or affiliate and issues the appropriate rewards and commissions in Bitcoin.

Tip: If you're not sure how to implement this, a web developer can set it up quickly using standard URL parameter capture and cookie storage — it's a common pattern.

What's Next

Was this article helpful?