Dual-sided incentives

Learn how to offer dual-sided incentives to your partners and the users they refer.

Steven Tey

Written by Steven Tey

Dub Partners Waitlist

Sign up today to get early access

With Dub Partners, you can create dual-sided incentives for your affiliate/referral programs, which gives special discounts to customers that 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 Partners.

Option 1: With Stripe coupon codes

If you're using Stripe for payments, you can follow these steps to set up dual-sided incentives on Dub:

Follow this guide to create a coupon code in Stripe with your desired parameters. Once the coupon code is created, be sure to note the unique coupon ID, which we will be using in subsequent steps to create a discount on Dub.

We also recommend creating the same coupon in Stripe's test mode, which will allow you to test the implementation in your preview environment before shipping it to production.

In your Program's Configuration page, click on the Discounts tab.

Program discounts tab

Select Create default discount to create your first program-wide discount:

Program discounts tab

Discount Type

  • One-off (only for the first sale)
  • Recurring (ongoing discounts, e.g. 3 months, 12 months)

Discount model

  • Percentage (e.g. 20%, 50%)
  • Flat (e.g. $30 off, $50 off)

Stripe coupon ID Input the ID of the Stripe coupon code you generated above here (should be a 8 alphanumeric character)

Lastly, you'll need to add the coupon logic to your Stripe checkout flow and leverage Dub's Customers API to determine if a user is eligible for a discount or not.

import { dub } from "@/lib/dub.ts"
 
 
const customer = await dub.customers.list({
  externalId: userId, // their user ID within your app
  includeExpandedFields: true,
})
 
 
const stripeSession = await stripe.checkout.sessions.create({
  success_url: "https://app.domain.com/upgraded",
  ...(customer.length > 0 && customer[0].discount?.couponId
    ? {
        discounts: [
          {
            coupon:
              process.env.NODE_ENV !== "production" &&
              customer.discount.couponTestId
                ? customer.discount.couponTestId
                : customer.discount.couponId,
          },
        ],
      }
    : { allow_promotion_codes: true }),
  ...
})

Once this is set up, eligible customers will automatically see the coupon code applied at checkout:

Stripe coupon applied

Option 2: With Shopify discount codes

We're planning to add support for dual-sided incentives with Shopify checkout soon – stay tuned! If you want early access to this, feel free to reach out to us.

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:

{
  "clickId": "xxx", // unique ID of the click event
  "partner": {
    "id": "pn_xxx", // unique ID of the partner on Dub
    "name": "John Doe", // name of the partner
    "image": "https://example.com/john.png" // avatar of the partner
  },
  "discount": {
    "id": "disc_xxx", // unique ID of the discount on Dub
    "amount": 25, // discount amount (either a percentage or a fixed amount)
    "type": "percentage", // type of the discount (either "percentage" or "fixed")
    "maxDuration": 3 // maximum duration of the discount in months
  }
}

To access this cookie data, we recommend using a cookie library like js-cookie – here's an example:

import Cookies from "js-cookie";
 
const dubPartnerData = Cookies.get("dub_partner_data");
const { partner, discount } = dubPartnerData ? JSON.parse(dubPartnerData) : {};
 
// Display a banner that says: "John referred you to Acme and gave you 25% off"
return (
  <div className="flex items-center gap-2">
    <img src={image} alt={name} className="size-6 rounded-full" />
    <p>
      {name} referred you to Acme and gave you {amount} {type} off
    </p>
  </div>
);

Here's an example of how the discount banner will look like:

A screenshot of the Dub partner data example
A screenshot of the Dub partner data example

Did this answer your question?