Integration Guide

Integrate affiliate tracking into your website

1. Add Tracking Script
Copy and paste this code before the closing </body> tag
<script>
  window.AFFILIATE_API_URL = 'https://fansfiliate.com';
</script>
<script src="https://fansfiliate.com/affiliate-tracker.js"></script>
2. Configure Stripe Webhook
Add this endpoint to your Stripe dashboard

Webhook URL:

https://fansfiliate.com/api/stripe/webhook

Required events:

  • invoice.payment_succeeded
  • charge.refunded
  • customer.subscription.deleted
Complete Documentation
Everything you need to know about the integration

Affiliate System Integration Guide

Quick Start

Add this script to your website's HTML, just before the closing </body> tag:

html
<script>
  window.AFFILIATE_API_URL = 'https://fansfiliate.com';
</script>
<script src="https://fansfiliate.com/affiliate-tracker.js"></script>

Track Conversions

When a user signs up or makes a purchase, call:

javascript
window.AffiliateTracker.trackConversion(stripeCustomerId);

Stripe Integration

Configure your Stripe webhooks to point to:

https://fansfiliate.com/api/stripe/webhook

Select these events:

  • invoice.payment_succeeded
  • charge.refunded
  • customer.subscription.deleted

Apply Discount for Referred Users

javascript
const discountCode = window.AffiliateTracker.getDiscountCode();
if (discountCode) {
  // Apply REFERRED10 for 10% off
  console.log('Discount code:', discountCode);
}

API Endpoints

Track Click

POST /api/trpc/tracking.trackClick

json
{
  "json": {
    "referralCode": "ABC123",
    "source": "https://example.com"
  }
}

Track Conversion

POST /api/trpc/tracking.trackConversion

json
{
  "json": {
    "referralCode": "ABC123",
    "customerId": "cus_..."
  }
}

Program Details

FeatureValue
Commission Rate20% recurring
Cookie Duration90 days
Minimum Payout$100
Payout MethodPayPal
Referral Discount10% (REFERRED10)

Testing

  1. Visit your site with ?ref=TEST123
  2. Check browser console for confirmation
  3. Complete a signup/purchase
  4. Call trackConversion(customerId)
  5. Verify in affiliate dashboard
Download Tracker Script
Self-host the tracking script on your own domain