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:
- Capture those parameters when the customer lands
- Store them (via cookies or local storage) so they persist as the customer browses
- 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.
What's Next
- Set up referral rewards — Configure what referrers and referred friends earn.
- Set up your affiliate program — Create affiliate links and commission structures.
- Connect BTCPay Server — If you haven't connected yet, start there first.
Related Articles
Was this article helpful?