docs
Affiliate & Partner Program

Affiliate & Partner Program

💡

NextSaaS comes with a built-in affiliate/partner system that allows you to create special landing pages with custom discounts for each partner.

How It Works

The affiliate system works through the via URL parameter, which can be used in two ways:

  1. Site-wide Affiliate Tracking: Any page on your website can be accessed with ?via=partner-name to track referrals and apply partner-specific discounts. For example:

    • yourdomain.com?via=partner-name
    • yourdomain.com/pricing?via=partner-name
    • yourdomain.com/any-page?via=partner-name
  2. Dedicated Partner Landing Pages: For a more customized experience, you can create special landing pages at /promo?via=partner-name with partner-specific content.

The system allows you to:

  • Apply automatic discounts for customers coming through partner links
  • Track referrals through URL parameters
  • Customize partner-specific content (logos, titles, discounts)
  • Create dedicated landing pages (optional)

Partner Landing Page Example

Setting Up Partners

1. Configure Partner Details

Partners are defined in src/lib/affiliate.ts. Add new partners to the PARTNERS object:

export const PARTNERS: { [key: string]: Partner } = {
  "partner-name": {
    title: "Special Offer for PartnerName Users",
    logo: "/path/to/partner-logo.png",
    link: "https://partner-website.com",
    code: "PARTNER20", // Optional promotion code
    discount: 0.2, // 20% discount (use decimal for percentage, number for fixed amount)
  },
};

2. Partner URL Structure

Each partner gets a unique URL in the format:

https://yourdomain.com/promo?via=partner-name

The partner-name in the URL parameter must match the key in your PARTNERS object.

3. Discount Types

You can configure two types of discounts:

  • Percentage Discount: Use a decimal between 0-1 (e.g., 0.2 for 20% off)
  • Fixed Amount Discount: Use a number ≥ 1 (e.g., 10000 for $100 off)

4. Referral Tracking

Referrals are tracked through the via URL parameter. You can:

  • Track conversions in your analytics platform using URL parameters
  • Create custom UTM parameters for more detailed tracking
  • Monitor partner performance through your analytics dashboard
ℹ️

Previous versions of NextSaaS included PromoteKit integration as an example tracking solution. The current version uses URL parameters for greater flexibility, allowing you to integrate with any analytics platform of your choice.

5. Environment Variables

Add the following to your .env file to configure affiliate tracking:

# PromoteKit ID for affiliate tracking
NEXT_PUBLIC_PROMOTEKIT_ID="{promotekit_id}"
ℹ️

While NextSaaS previously used PromoteKit as the default tracking solution, you can now: - Use PromoteKit by setting the NEXT_PUBLIC_PROMOTEKIT_ID in your environment variables - Replace PromoteKit with your preferred analytics solution - Remove tracking by omitting the environment variable

Customizing the Landing Page

The partner landing page (src/app/(main)/(marketing)/promo/page.tsx) can be customized with:

  • Partner logo
  • Custom title and description
  • Special offer badge
  • Pricing plans with automatic discount application
  • Custom hero image

Testing Partner Links

  1. Create a test partner in PARTNERS
  2. Visit /promo?via=your-partner-name
  3. Verify the discount is applied in the pricing plans
  4. Test the checkout process to ensure discounts are properly applied

Best Practices

  1. Partner Assets: Store partner logos in the public directory
  2. URL Naming: Use lowercase, hyphenated names for partner identifiers
  3. Testing: Always test the full purchase flow with each partner configuration
  4. Analytics: Set up proper UTM parameters for tracking in your analytics platform

Example Partner Configuration

export const PARTNERS: { [key: string]: Partner } = {
  "acme-corp": {
    title: "Exclusive Offer for Acme Corp Users",
    logo: "/partners/acme-logo.png",
    link: "https://acme.com",
    code: "ACME25", // promo code needs to be created in Stripe
    discount: 0.25,
  },
  "startup-deals": {
    title: "Special StartupDeals Discount",
    logo: "/partners/startup-deals-logo.png",
    link: "https://startupdeals.com",
    code: "STARTUP100", // promo code needs to be created in Stripe
    discount: 10000, // $100 off
  },
};