All Collections
Campaigns
Double-sided incentives
Double-sided incentives

How to apply coupons to referred customers

Kyle Fox avatar
Written by Kyle Fox
Updated over a week ago

Note: double-sided incentives are part of the Growth plan. 

"Double-sided incentives" allow you to apply coupons to referred customers, and are a great way to increase the conversion rate for affiliate traffic. Not only does this increase your revenue, higher conversion rates help motivate affiliates and keep them engaged — the more successful your affiliates are, the more they'll want to promote you!

We call them double-sided (or two-sided) incentives because in addition to the affiliate's incentive to drive traffic (i.e. the commission) the visitors also have an incentive to convert (i.e. the coupon).

This article will show you how to add a double-sided incentive (coupon) to your Rewardful campaign.

Tip for advanced users: the coupon data will also be accessible through our JavaScript API. You can use this to customize your website or populate coupon form fields based on the current coupon.

Step 1: Create a coupon in Stripe

Create a new coupon from your Stripe dashboard. This will be the coupon that is applied to new customers who sign up.

You can choose any type (fixed amount or percentage) and duration (forever, once, multiple months or how many times the coupon will be applied).

NOTE: Redemption limits options should be unchecked (in order to keep the coupon valid):

Once you've created the coupon, you'll need to copy and paste the ID into Rewardful. You can find the ID here:

Step 2: Paste the coupon ID into Rewardful

On your Edit Campaign page, click the "Toggle advanced settings" link in the bottom right corner. Paste the coupon ID into the text field labelled "Stripe Coupon ID" as shown below:

Step 3: (Code) Pass the coupon back to Stripe

Note: This step will need to be performed by a developer.

The Stripe coupon ID will be part of the tracking cookie that is generated when the customer used an affiliate link. It has to be retrieved via Rewardful.coupon. If there is no coupon attached to your campaign, or the visitor isn't a referral, the value Rewardful.coupon will be empty.

You must then pass the coupon ID to Stripe, similar to how referral is passed as metadata.

For example, your Ruby code might look something like this:

Stripe::Customer.create(
  email: params[:email],
  metadata: { referral: params[:referral] },
  coupon: params[:coupon]
)

Note the coupon: params[:coupon] being passed to Stripe.

This will add the coupon to the Stripe customer and apply a discount to their invoices based on the coupon settings.

⚠️ IMPORTANT ⚠️

Stripe's API will raise an error if you attempt to pass an invalid coupon code. Rewardful attempts to never include an invalid coupon code, but we recommend implementing error handling nonetheless — as always.

One approach is to validate the coupon by attempting to retrieve it from Stripe before adding it to the customer object. For example, in Ruby:

coupon = Stripe::Coupon.retrieve(params[:coupon]) rescue nil

Stripe::Customer.create(
  email: params[:email],
  metadata: { referral: params[:referral] },
  coupon: coupon
)

Retrieving the coupon first (and handling any Stripe API errors) guarantees you'll never encounter a "No such coupon" error when creating the customer.

Have more questions?

If you have more questions or would like code samples in another programming language, please let us know at hello@getrewardful.com or by live chat. We'll be happy to help!

Did this answer your question?