Double-sided incentives create a win-win situation where affiliates earn commissions while their referred customers automatically receive discount codes. This powerful feature increases both affiliate motivation and customer conversion rates by providing immediate value to every referred visitor.
Affonso supports two types of coupon codes for double-sided incentives:
- Program-Wide Coupons: A single coupon code shared across all affiliates in a program. Every referred customer sees the same discount.
- Unique Affiliate Coupons: Individual coupon codes per affiliate. Each affiliate can have their own personalized discount code(s), enabling more targeted promotions and better tracking.
You can use either type — or both together. When a customer arrives via an affiliate referral link, the Affonso tracking pixel automatically makes both the program-wide coupon and the affiliate's unique coupons available in the affonso_data cookie.
Option 1: Program-Wide Coupon
Program-wide coupons are the simplest way to get started. One coupon code applies to all affiliates in the program.
Create Program-Wide Coupon
- Navigate to your Affiliate Program Settings
- Scroll down to the "Program-Wide Coupon Code" section
- Click "Create Program Coupon"
- Configure your coupon:
- Discount Type: Choose percentage or fixed amount
- Discount Value: Set your discount amount (e.g., 20% or $10)
- Duration: Select "once", "forever", or "repeating"
- Coupon Code: Enter a memorable code (e.g., "WELCOME20")
- Click "Create Coupon" to generate it across all your connected payment providers
The coupon will be automatically created in Stripe, DODO, and Polar (depending on your integrations) and becomes immediately available to all customers.
Access the Coupon in Your Checkout
// Get the program-wide discount
const discount = window.Affonso.getDiscount();
if (discount) {
console.log(discount.promoCode); // e.g., "WELCOME20"
console.log(discount.couponId); // Payment provider coupon ID
console.log(discount.amount); // e.g., 20
console.log(discount.type); // "percentage" or "fixed"
}Option 2: Unique Affiliate Coupons
Unique affiliate coupons give each affiliate their own personalized discount code. This is great for influencer partnerships, brand ambassadors, or any scenario where you want affiliates to promote their own codes.
Create Unique Coupons for Affiliates
You can create unique coupon codes for individual affiliates through:
- Dashboard: Navigate to the affiliate's profile and create a coupon code in the "Coupon Codes" section
- API: Use the Affonso API to create coupons programmatically via
POST /v1/coupons - Self-Service: Enable self-service coupon creation to let affiliates create their own codes from the affiliate portal
Access Affiliate Coupons in Your Checkout
When a customer arrives via an affiliate's referral link, all of that affiliate's unique coupons are available:
// Get all unique coupons for this affiliate
const coupons = window.Affonso.getAffiliateCoupons(); // Returns array
if (coupons.length > 0) {
const coupon = coupons[0]; // Most recently created coupon
console.log(coupon.promoCode); // e.g., "JOHN20"
console.log(coupon.couponId); // Payment provider coupon ID
console.log(coupon.amount); // e.g., 20
console.log(coupon.type); // "percentage" or "fixed"
}Using Both Together
You can combine both coupon types. A common pattern is to prefer the affiliate's unique coupon when available, and fall back to the program-wide coupon:
// Prefer affiliate's unique coupon, fall back to program-wide
const affiliateCoupons = window.Affonso.getAffiliateCoupons();
const programDiscount = window.Affonso.getDiscount();
const coupon = affiliateCoupons.length > 0
? affiliateCoupons[0] // Use affiliate's unique coupon
: programDiscount; // Fall back to program-wide
if (coupon) {
fetch('/api/checkout', {
method: 'POST',
body: JSON.stringify({
couponId: coupon.couponId,
// ... your other checkout data
})
});
}For a complete implementation guide on auto-applying coupons at checkout, see Auto-Apply Affiliate Coupons at Checkout.
How It Works
- Customer clicks affiliate link with referral parameter (e.g.,
?via=affiliate123) - Affonso tracking pixel automatically detects the referral and fetches coupon data
- Coupon information is stored in the
affonso_datacookie — both program-wide and affiliate-specific coupons - Your checkout flow retrieves the coupon and applies it during payment
- Customer gets discount while affiliate earns commission on the sale
Access Methods
You can access coupon data using these JavaScript methods:
// Get program-wide discount (one per affiliate program)
const discount = window.Affonso.getDiscount(); // Returns discount object or null
// Get unique affiliate coupons (all coupons for this specific affiliate)
const coupons = window.Affonso.getAffiliateCoupons(); // Returns array (empty if none)
// Get all data
const data = window.Affonso.getData();
// Example discount/coupon object:
// {
// amount: 20,
// type: "percentage",
// maxDuration: "once",
// couponId: "stripe_coupon_id",
// promoCode: "WELCOME20"
// }

