Quickstart
Prerequisites
- A SaaS product with a website
- A Stripe or Paddle account for payment processing
- Access to your site's HTML (to install the tracking script)
Step 1: Create your program
Sign up at app.affihub.com and create your affiliate program. You'll receive:
- Program ID — Used in the tracking script and API calls
- API Key — For server-side API access
- Webhook URLs — For connecting Stripe or Paddle
You can find all of these in Settings & Keys in your provider dashboard.
Step 2: Install the tracking script
Add the Affihub tracking script to every page of your website. Place it before the closing </body> tag:
<script
src="https://api.affihub.com/affihub.js"
data-program="YOUR_PROGRAM_ID"
></script>Replace YOUR_PROGRAM_ID with the Program ID from your dashboard.
The script does three things:
- Detects
?ref=partner-slugin the URL - Stores the referral in
localStoragefor 90 days - Sends a click event to the Affihub API
The script is lightweight (~2KB) and loads asynchronously. It won't affect your page load performance.
Step 3: Connect your payment provider
Affihub needs to know when a referred visitor makes a purchase. This is done via webhooks.
Stripe
- In your Stripe Dashboard, go to Developers → Webhooks
- Add a new endpoint:
https://api.affihub.com/webhooks/stripe?program_id=YOUR_PROGRAM_ID - Select events:
checkout.session.completedandinvoice.paid - Copy the Webhook Signing Secret
- In your Affihub dashboard, go to Settings and paste it in the Stripe Webhook Secret field
Then pass the referral data in your checkout session:
const session = await stripe.checkout.sessions.create({
// ... your checkout config
client_reference_id: AffiHub.getRef()?.ref || undefined,
});Paddle
- In your Paddle Dashboard, go to Developer Tools → Notifications
- Add a new destination:
https://api.affihub.com/webhooks/paddle?program_id=YOUR_PROGRAM_ID - Select events:
transaction.completed,subscription.canceled,adjustment.updated - Copy the Webhook Secret Key
- In your Affihub dashboard, paste it in the Paddle Webhook Secret field
Pass the referral in your checkout:
Paddle.Checkout.open({
items: [{ priceId: "pri_xxx", quantity: 1 }],
customData: {
affihub_program: "YOUR_PROGRAM_ID",
affihub_ref: AffiHub.getRef()?.ref || "",
},
});Step 4: Invite your first partner
In the provider dashboard, go to Partners → Add Partner. Enter their name, email, and slug:
- Slug — The unique identifier used in referral links. For example, if the slug is
john, the referral link ishttps://yoursite.com?ref=john. - Commission — Leave blank to use the program default, or set a custom percentage for this partner.
The partner will receive an email with instructions to access their portal at portal.affihub.com.
Step 5: Verify the integration
Test the full flow:
- Visit your website with a test referral link:
https://yoursite.com?ref=partner-slug - Open your browser's developer console and run
AffiHub.getRef()— you should see{ref: "partner-slug", program: "YOUR_PROGRAM_ID"} - Complete a test purchase
- Check your Affihub dashboard — you should see a new commission
Stripe test mode webhooks work with Affihub. Use test mode to verify your integration before going live.
What's next?
- Install Tracking Script — Deep dive into the tracking script and its API
- Stripe Integration — Complete Stripe setup guide
- Paddle Integration — Complete Paddle setup guide
- How It Works — Understand the full attribution flow