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.
When you create a program-wide coupon, it automatically becomes available to all customers who visit your site through any affiliate referral link, creating seamless incentives without additional setup per affiliate.
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.
Add Coupon Logic to Checkout Flow
To automatically apply program-wide coupons, you need to retrieve the couponId
from the affonso_data
cookie and pass it to your payment provider during checkout session creation. The cookie contains the discount information that was set when the customer arrived via an affiliate referral link.
Your frontend checkout flow should extract this data and send it to your backend, which then includes the coupon ID in the payment provider's checkout session API call.
Implementation
// Frontend: Get discount data
const discount = window.Affonso.getDiscount(); // Single program-wide discount
// Send to your backend with coupon ID
if (discount) {
fetch('/api/checkout', {
method: 'POST',
body: JSON.stringify({
couponId: discount.couponId,
// ... your other checkout data
})
});
}
Backend Integration
Pass the couponId
to your payment provider's checkout session:
How It Works
- Customer clicks affiliate link with referral parameter (e.g.,
?via=affiliate123
) - Affonso tracking pixel automatically detects the referral and fetches program-wide coupon data
- Coupon information is stored in the
affonso_data
cookie for easy access - 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 the coupon data using these JavaScript methods:
// Get program discount (one per affiliate program)
const discount = window.Affonso.getDiscount(); // Returns discount or null
// Get all data (includes discount and future extensions)
const data = window.Affonso.getData();
// Example discount object:
// {
// amount: "20",
// type: "percentage",
// maxDuration: "once",
// couponId: "stripe_coupon_id",
// promoCode: "WELCOME20"
// }