AffihubDocs
DocsGetting StartedQuickstart

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:

  1. Detects ?ref=partner-slug in the URL
  2. Stores the referral in localStorage for 90 days
  3. 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

  1. In your Stripe Dashboard, go to Developers → Webhooks
  2. Add a new endpoint: https://api.affihub.com/webhooks/stripe?program_id=YOUR_PROGRAM_ID
  3. Select events: checkout.session.completed and invoice.paid
  4. Copy the Webhook Signing Secret
  5. 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

  1. In your Paddle Dashboard, go to Developer Tools → Notifications
  2. Add a new destination: https://api.affihub.com/webhooks/paddle?program_id=YOUR_PROGRAM_ID
  3. Select events: transaction.completed, subscription.canceled, adjustment.updated
  4. Copy the Webhook Secret Key
  5. 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 is https://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:

  1. Visit your website with a test referral link: https://yoursite.com?ref=partner-slug
  2. Open your browser's developer console and run AffiHub.getRef() — you should see {ref: "partner-slug", program: "YOUR_PROGRAM_ID"}
  3. Complete a test purchase
  4. 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?