Skip to main content
This feature is only available on Business plans and above.
With Dub Partners, you can create dual-sided incentives for your affiliate/referral programs, which give special discounts to customers who sign up via a referral link.
Some examples include:
  • 25% discount for the first 12 months
  • 30% lifetime discount
  • $50 one-off discount
This can drive powerful word-of-mouth growth as partners are more likely to share their link if it gives their audience/user base additional discounts, and on the other hand, their users are more likely to click on their links as well if they’re getting a special deal. In this article, we’ll learn how to set up dual-sided incentives with Dub.

Stripe coupons / promotion codes

There are two ways to set up dual-sided incentives if you’re using Stripe: If you’re using Stripe for payments, you can follow these steps to set up direct link-based discounts for your partner referral links:
Link-based discounts provide better attribution accuracy since you get visibility into the customer’s geolocation, device info, referrer details, and UTM data.The trade-off here is that it requires some engineering work to set up.
1

Create a discount on Dub

First, navigate to the partner group that you want to create a discount for. Under the Discount tab, you’ll be able to create a discount for the group
Group discounts page
If you already have a discount set up for your default group, you can just duplicate it. If not, click Create to create your first group discount:
Program discounts tab
New Stripe couponIf you don’t have a coupon set up on Stripe yet, you can use the New Stripe coupon option to create a new coupon based on the discount type (percentage vs flat), amount, and duration set in Dub.Use Stripe coupon IDIf you already have an existing coupon on Stripe, you can enter the Stripe coupon ID (should be an 8 alphanumeric code) under the Use Stripe coupon ID option.
Since Stripe doesn’t support updating coupons after creation, you’d need to delete your discount in Dub and create a new one if you want to update any of the discount parameters.Note: Deleting a discount on Dub does not delete the corresponding Stripe coupon.
2

Add coupon logic to checkout flow

The key to implementing link-based discounts is to check if a customer is eligible for a discount using Dub’s Customers API, then automatically apply the appropriate Stripe coupon to their checkout session.Here’s how the flow works:
  1. When a user clicks a partner referral link, Dub tracks them as a potential customer
  2. During checkout, you query the Dub Customers API using the user’s ID
  3. If they’re eligible for a discount, you apply the coupon to their Stripe checkout session
  4. If not, you allow them to enter promotion codes manually
Once this is set up, eligible customers will automatically see the coupon code applied at checkout:
Stripe coupon applied

Option 2: Using Stripe promo codes (no code required)

If you prefer a no-code solution, you can set up Stripe promo-code-based discounts for your partners.
Stripe promo-code-based discounts is much easier to set up (no code required).However, you do sacrifice on attribution accuracy since you won’t have any insights into the customer’s geolocation, device info, referrer details, and UTM data. Our Stripe integration will try to derive the customer’s location based on their Stripe billing address, but it can sometimes be inaccurate.
1

Create a discount on Dub

First, navigate to the partner group that you want to create a discount for. Under the Discount tab, you’ll be able to create a discount for the group
Group discounts page
If you already have a discount set up for your default group, you can just duplicate it. If not, click Create to create your first group discount:
Program discounts tab
New Stripe couponIf you don’t have a coupon set up on Stripe yet, you can use the New Stripe coupon option to create a new coupon based on the discount type (percentage vs flat), amount, and duration set in Dub.Use Stripe coupon IDIf you already have an existing coupon on Stripe, you can enter the Stripe coupon ID (should be an 8 alphanumeric code) under the Use Stripe coupon ID option.
Since Stripe doesn’t support updating coupons after creation, you’d need to delete your discount in Dub and create a new one if you want to update any of the discount parameters.Note: Deleting a discount on Dub does not delete the corresponding Stripe coupon.
2

Create your partner code

Open the partner profile that you’d like to create a discount code for, then click Create Code in the “Discount codes” section.
Partner links page
Here you can select which referral link you’d like to associate the code with. Then you can create the discount code.
Partner links page
Discount codes cannot be edited after creation, so ensure that you have everything correct before creating the code
After the code has been created, you’ll see its value populated in the Discount Code section, and it is ready for use. In the Partner Dashboard, they’ll also see the associated discount code within their partner links.
Partner links page with discount code

Shopify discount codes

Use the Shopify discount provider when you sell through Shopify. Dub creates partner discount codes in your store automatically, and attributes the sale when a customer applies a partner’s code at checkout — even if they didn’t click a referral link.
This requires the Dub Shopify app. Dub creates and deletes discount codes in your Shopify store automatically.
1

Connect the Dub Shopify app

Install the Dub Shopify App and connect it to your Dub workspace. Follow the Shopify integration guide if you haven’t already.
The Dub Shopify app
The app needs permission to create discount codes (write_discounts). If you installed it before this permission was added, reinstall or upgrade the app from the Shopify App Store.
2

Create a Shopify discount on Dub

First, navigate to the partner group that you want to create a discount for. Under the Discount tab, you’ll be able to create a discount for the group.
Group discounts page
If you already have a discount set up for your default group, you can just duplicate it. If not, click Create to create your first group discount:
Program discounts tab
Set Discount provider to Shopify, then choose the discount type (percentage vs flat), amount, and duration.
Since discount conditions can’t be updated after creation, you’d need to delete your discount in Dub and create a new one if you want to change the type, amount, or duration.Deleting a discount or discount code on Dub also disables the corresponding codes in Shopify.
3

Create partner discount codes

Open the partner profile that you’d like to create a discount code for, then click Create Code in the Discount codes section.
Partner links page
Select which referral link you’d like to associate the code with, then create the discount code. If you omit a custom code, Dub generates one from the partner’s name.
Partner links page
Dub immediately creates a matching code in your Shopify store. Shopify codes created by Dub:
  • Apply to all products
  • Can be used once per customer
  • Work on one-time purchases and subscriptions
  • Use your discount duration as Shopify subscription billing cycles (one-time → first cycle, a set number of months → that many cycles, lifetime → applies indefinitely)
Discount codes cannot be edited after creation, so ensure that you have everything correct before creating the code.
After the code has been created, you’ll see its value populated in the Discount Code section, and it is ready for use. In the Partner Dashboard, they’ll also see the associated discount code within their partner links.
Partner links page with discount code

Custom discount provider

Use the Custom discount provider when you manage promo codes in your own system (eg: WooCommerce, Squarespace, etc.) instead of Stripe or Shopify. Dub remains the source of truth for partner discounts and discount codes; your application creates and disables the matching codes by listening to webhooks.
1

Create a custom discount on Dub

First, navigate to the partner group that you want to create a discount for. Under the Discount tab, you’ll be able to create a discount for the group.
Group discounts page
If you already have a discount set up for your default group, you can just duplicate it. If not, click Create to create your first group discount:
Program discounts tab
Set Discount provider to Custom, then choose the discount type (percentage vs flat), amount, and duration.
Since discount conditions can’t be updated after creation, you’d need to delete your discount in Dub and create a new one if you want to change the type, amount, or duration.
2

Create partner discount codes

Open the partner profile that you’d like to create a discount code for, then click Create Code in the Discount codes section.
Partner links page
Select which referral link you’d like to associate the code with, then create the discount code. If you omit a custom code, Dub generates one from the partner’s name.
Partner links page
You can also create or delete discount codes via the API.
Discount codes cannot be edited after creation, so ensure that you have everything correct before creating the code.
3

Sync codes with your system

Create a webhook subscribed to discount_code.created and discount_code.deleted.Your endpoint should:
  1. Verify the webhook signature
  2. On discount_code.created, create the matching promo code in your system using data.code and the nested discount (amount, type, duration)
  3. On discount_code.deleted, disable or delete that promo code in your system
  4. Return a 2xx status code on success
These events also fire when codes are auto-provisioned, and when a code is removed automatically (for example if a partner is banned, deactivated, or moved to a group without an equivalent discount).

Auto-provision discount codes

When enabled, discount codes will be automatically created for all existing partners in this group and future partners when they join this group.
Auto provision discount codes

Displaying discount banner

Once you’ve set up dual-sided incentives, a potential next step would be to display the discount information on your pricing page / landing page hero. To do that, all you need is to install the Dub Analytics script with client-side click-tracking enabled – then, when someone lands on your site via a valid referral link, the script will automatically fetch the partner and discount data for you. This data will be stored as a JSON-stringified object in the dub_partner_data cookie in the following format:
You can access partner and discount data in your application code using the useAnalytics() hook. If you’re working in a non-React environment, you can use the DubAnalytics object directly. Here is a quick example of how you can display a discount banner using the useAnalytics() hook:
Here’s an example of how the discount banner will look like:
A screenshot of the Dub partner data example