> ## Documentation Index
> Fetch the complete documentation index at: https://dub.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Offering dual-sided incentives

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

> [!TIP]
>
> This feature is only available on [Business plans and
> above](https://dub.co/pricing).

With [Dub Partners](https://dub.co/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.

<video src="https://assets.dub.co/cms/dub-partners-dual-sided-incentives.mp4" loop autoPlay muted playsInline />

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.

By default, the discount is configured at the [partner group](/help/article/partner-groups) level. You can also override it for an individual [partner](#partner-level-discounts) or [link](#link-level-discounts).

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:

### Option 1: Direct link-based discounts (recommended)

If you're using Stripe for payments, you can follow these steps to set up direct link-based discounts for your partner referral links:

> [!NOTE]
>
> 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](https://assets.dub.co/cms/group-discounts-empty.png)

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](https://mintcdn.com/dub/L3oLlR_6442i0NMM/images/dub-partners/new-discount-reward.png?fit=max\&auto=format\&n=L3oLlR_6442i0NMM\&q=85\&s=064929c47755ba15d9fd1bc764f39dbd)

**New Stripe coupon**

If 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 ID**

If 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.

> [!WARNING]
>
> 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](/docs/api-reference/customers/list), 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](/docs/api-reference/customers/list) 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

```ts TypeScript expandable theme={null}
import { dub } from "@/lib/dub.ts";
import Stripe from "stripe";

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);

// Get customer discount eligibility from Dub
const customers = await dub.customers.list({
  externalId: userId, // their user ID within your app
  includeExpandedFields: true,
});

const customerDiscount = customers.length > 0 ? customers[0].discount : null;

// Create Stripe checkout session with conditional discount
const stripeSession = await stripe.checkout.sessions.create({
  success_url: "https://app.domain.com/upgraded",
  cancel_url: "https://app.domain.com/pricing",
  line_items: [
    {
      price: "price_1MotwRLkdIwHu7ixYcPLm5uZ",
      quantity: 1,
    },
  ],
  mode: "subscription", // or "payment" for one-time purchases
  ...(customerDiscount
    ? {
        // Apply discount automatically if customer is eligible
        discounts: [
          {
            coupon:
              process.env.NODE_ENV !== "production" &&
              customerDiscount.couponTestId
                ? customerDiscount.couponTestId
                : customerDiscount.couponId,
          },
        ],
      }
    : {
        // Allow manual promo code entry if no automatic discount
        allow_promotion_codes: true,
      }),
  customer_email: userEmail,
  metadata: {
    userId: userId,
    ...(customerDiscount && { dubDiscountId: customerDiscount.id }),
  },
});
```

```python Python expandable theme={null}
import stripe
from dub import Dub
import os

stripe.api_key = os.environ.get("STRIPE_SECRET_KEY")
dub_client = Dub(token=os.environ.get("DUB_API_KEY"))

user_id = "user_123"  # the user's ID in your app

# Get customer discount eligibility from Dub
customers = dub_client.customers.list(
    email=None,
    external_id=user_id,
    include_expanded_fields=True
)

# Prepare checkout session parameters
session_params = {
    "success_url": "https://app.domain.com/upgraded",
    "cancel_url": "https://app.domain.com/pricing",
    "line_items": [{"price": "price_1MotwRLkdIwHu7ixYcPLm5uZ", "quantity": 1}],
    "mode": "subscription",  # or "payment" for one-time purchases
    "customer_email": user_email,
    "metadata": {
        "userId": user_id,
    },
}

# Apply discount if customer is eligible
if customers and hasattr(customers[0], "discount") and customers[0].discount and customers[0].discount.coupon_id:
    coupon_id = customers[0].discount.coupon_test_id if (
        os.environ.get("NODE_ENV") != "production"
    ) and hasattr(customers[0].discount, "coupon_test_id") else customers[0].discount.coupon_id

    session_params["discounts"] = [{"coupon": coupon_id}]
    session_params["metadata"]["dubDiscountId"] = customers[0].discount.id
else:
    session_params["allow_promotion_codes"] = True

# Create the checkout session
session = stripe.checkout.Session.create(**session_params)
```

```ruby Ruby expandable theme={null}
require 'stripe'
require 'dub'

# Initialize clients
Stripe.api_key = ENV['STRIPE_SECRET_KEY']

dub_client = ::OpenApiSDK::Dub.new
dub_client.config_security(
  ::OpenApiSDK::Shared::Security.new(
    token: ENV['DUB_API_KEY'],
  )
)

# Get customer discount eligibility from Dub
user_id = "user_123" # the user's ID in your app
customers = dub_client.customers.list(
  ::OpenApiSDK::Operations::ListCustomersRequest.new(
    request: ::OpenApiSDK::Operations::ListCustomersRequestBody.new(
      external_id: user_id,
      include_expanded_fields: true
    )
  )
)

# Create checkout session parameters
session_params = {
  success_url: 'https://app.domain.com/upgraded',
  cancel_url: 'https://app.domain.com/pricing',
  line_items: [
    {
      price: 'price_1MotwRLkdIwHu7ixYcPLm5uZ',
      quantity: 1,
    },
  ],
  mode: 'subscription', # or 'payment' for one-time purchases
  customer_email: user_email,
  metadata: {
    userId: user_id,
  },
}

# Apply discount if customer is eligible
if customers.respond_to?(:customers) &&
  !customers.customers.empty? &&
  customers.customers[0].discount &&
  customers.customers[0].discount.coupon_id

  coupon_id = if ENV['NODE_ENV'] != 'production' &&
                customers.customers[0].discount.coupon_test_id
                customers.customers[0].discount.coupon_test_id
              else
                customers.customers[0].discount.coupon_id
              end

  session_params[:discounts] = [{ coupon: coupon_id }]
  session_params[:metadata][:dubDiscountId] = customers.customers[0].discount.id
else
  session_params[:allow_promotion_codes] = true
end

# Create the checkout session
session = Stripe::Checkout::Session.create(session_params)
```

```go Go expandable theme={null}
package main

import (
    "context"
    "os"

    "github.com/stripe/stripe-go/v72"
    "github.com/stripe/stripe-go/v72/checkout/session"
    "github.com/dubinc/go-sdk/dub"
    "github.com/dubinc/go-sdk/operations"
)

func main() {
    // Initialize clients
    stripe.Key = os.Getenv("STRIPE_SECRET_KEY")

    dubClient := dub.New(
        dub.WithSecurity(os.Getenv("DUB_API_KEY")),
    )

    // Get customer discount eligibility from Dub
    userId := "user_123" // the user's ID in your app
    ctx := context.Background()

    listRequest := operations.ListCustomersRequest{
        Request: &operations.ListCustomersRequestBody{
            ExternalId: &userId,
            IncludeExpandedFields: true,
        },
    }

    customers, err := dubClient.Customers.List(ctx, listRequest)
    if err != nil {
        // Handle error
        return
    }

    // Create checkout session parameters
    params := &stripe.CheckoutSessionParams{
        SuccessURL: stripe.String("https://app.domain.com/upgraded"),
        CancelURL:  stripe.String("https://app.domain.com/pricing"),
        LineItems: []*stripe.CheckoutSessionLineItemParams{
            {
                Price:    stripe.String("price_1MotwRLkdIwHu7ixYcPLm5uZ"),
                Quantity: stripe.Int64(1),
            },
        },
        Mode:          stripe.String(string(stripe.CheckoutSessionModeSubscription)),
        CustomerEmail: stripe.String(userEmail),
    }

    // Add metadata
    params.AddMetadata("userId", userId)

    // Apply discount if customer is eligible
    if len(customers.Customers) > 0 && customers.Customers[0].Discount != nil && customers.Customers[0].Discount.CouponId != nil {
        var couponId string
        if os.Getenv("NODE_ENV") != "production" && customers.Customers[0].Discount.CouponTestId != nil {
            couponId = *customers.Customers[0].Discount.CouponTestId
        } else {
            couponId = *customers.Customers[0].Discount.CouponId
        }

        params.Discounts = []*stripe.CheckoutSessionDiscountParams{
            {
                Coupon: stripe.String(couponId),
            },
        }
        params.AddMetadata("dubDiscountId", *customers.Customers[0].Discount.Id)
    } else {
        params.AllowPromotionCodes = stripe.Bool(true)
    }

    // Create the checkout session
    s, err := session.New(params)
    if err != nil {
        // Handle error
        return
    }
}
```

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

![Stripe coupon applied](https://assets.dub.co/cms/stripe-coupon-applied.png)

### 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.

> [!NOTE]
>
> 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](https://assets.dub.co/cms/group-discounts-empty.png)

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](https://mintcdn.com/dub/L3oLlR_6442i0NMM/images/dub-partners/new-discount-reward.png?fit=max\&auto=format\&n=L3oLlR_6442i0NMM\&q=85\&s=064929c47755ba15d9fd1bc764f39dbd)

**New Stripe coupon**

If 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 ID**

If 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.

> [!WARNING]
>
> 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](https://assets.dub.co/cms/partner-create-code.png)

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](https://assets.dub.co/cms/new-discount-code.png)

> [!WARNING]
>
> 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](https://assets.dub.co/cms/partner-code-created.png)

## 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.

> [!NOTE]
>
> This requires the [Dub Shopify app](/docs/integrations/shopify). Dub creates
> and deletes discount codes in your Shopify store automatically.

**1. Connect the Dub Shopify app**

Install the [Dub Shopify App](https://d.to/shopify/app) and connect it to your Dub workspace. Follow the [Shopify integration guide](/docs/integrations/shopify) if you haven't already.

![The Dub Shopify app](https://mintcdn.com/dub/S5CJNHicyu5NWQ7r/images/shopify/shopify-app.png?fit=max\&auto=format\&n=S5CJNHicyu5NWQ7r\&q=85\&s=db64b4f582cc7fbcf8ab3c3f419513ba)

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](https://apps.shopify.com/dub-conversion-tracking).

**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](https://assets.dub.co/cms/group-discounts-empty.png)

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](https://mintcdn.com/dub/lZuUBEKDlN1KLwNY/images/dub-partners/create-shopify-discount.png?fit=max\&auto=format\&n=lZuUBEKDlN1KLwNY\&q=85\&s=d81b6ea087c3c6fe7a2d8e33dea11492)

Set **Discount provider** to **Shopify**, then choose the discount type (percentage vs flat), amount, and duration.

> [!WARNING]
>
> 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](https://assets.dub.co/cms/partner-create-code.png)

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](https://assets.dub.co/cms/new-discount-code.png)

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)

> [!WARNING]
>
> 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](https://assets.dub.co/cms/partner-code-created.png)

## 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](https://assets.dub.co/cms/group-discounts-empty.png)

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](https://mintcdn.com/dub/lZuUBEKDlN1KLwNY/images/dub-partners/create-custom-discount.png?fit=max\&auto=format\&n=lZuUBEKDlN1KLwNY\&q=85\&s=0db62f2962c25a9d0a623085559254a6)

Set **Discount provider** to **Custom**, then choose the discount type (percentage vs flat), amount, and duration.

> [!WARNING]
>
> 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](https://assets.dub.co/cms/partner-create-code.png)

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](https://assets.dub.co/cms/new-discount-code.png)

> [!TIP]
>
> You can also [create](/docs/api-reference/discount-codes/create) or
> [delete](/docs/api-reference/discount-codes/delete) discount codes via the
> API.

> [!WARNING]
>
> 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](/docs/webhooks/introduction) subscribed to [`discount_code.created`](/docs/webhooks/events/discount-code-created) and [`discount_code.deleted`](/docs/webhooks/events/discount-code-deleted).

Your endpoint should:

1. [Verify the webhook signature](/docs/webhooks/verify-webhook-requests)
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](#auto-provision-discount-codes), and when a code is removed automatically (for example if a partner is banned, deactivated, or moved to a group without an equivalent discount).

```typescript theme={null}
export const POST = async (req: Request) => {
  const webhookSignature = req.headers.get("Dub-Signature");
  if (!webhookSignature) {
    return new Response("No signature provided.", { status: 401 });
  }

  const secret = process.env.DUB_WEBHOOK_SECRET;
  if (!secret) {
    return new Response("No secret provided.", { status: 401 });
  }

  const rawBody = await req.text();
  const computedSignature = crypto
    .createHmac("sha256", secret)
    .update(rawBody)
    .digest("hex");

  if (webhookSignature !== computedSignature) {
    return new Response("Invalid signature", { status: 400 });
  }

  const payload = JSON.parse(rawBody);

  if (payload.event === "discount_code.created") {
    // Create the promo code in your system
    // payload.data.code, payload.data.discount
  }

  if (payload.event === "discount_code.deleted") {
    // Disable the promo code in your system
    // payload.data.code
  }

  return new Response("OK");
};
```

## 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.

> [!NOTE]
>
> Discount codes are only auto-provisioned for a partner's [default
> links](/help/article/partner-link-settings). Links that a partner creates
> themselves don't get a discount code automatically.

![Auto provision discount codes](https://mintcdn.com/dub/L3oLlR_6442i0NMM/images/dub-partners/auto-provision-code.png?fit=max\&auto=format\&n=L3oLlR_6442i0NMM\&q=85\&s=683646cf0f513855cbad822e40d7f387)

## Partner-level discounts

> [!TIP]
>
> Partner-level and link-level discounts are only available on [Advanced plans
> and above](https://dub.co/pricing).

By default, every partner uses the discount configured for their [partner group](/help/article/partner-groups). If you want to make an exception without creating a whole new group, you can override the discount for a single partner.

Partner-level discounts apply to one partner across all of their links, including links they create later, unless a link has its own [link-level override](#link-level-discounts).

Open the partner's details page from **All Partners**. The **Rewards** card on the right shows the discount currently in effect for that partner.

![Partner details](https://mintcdn.com/dub/X_Zj60OJkr-kJxT1/images/dub-partners/linklevel-reward-partnerlocation.png?fit=max\&auto=format\&n=X_Zj60OJkr-kJxT1\&q=85\&s=6b207d0d00a3d24cd23931447914134e)

Click the **edit** icon on the discount row to open the override modal.

![Partner edit](https://mintcdn.com/dub/X_Zj60OJkr-kJxT1/images/dub-partners/linklevel-reward-partnerlocation-edit.png?fit=max\&auto=format\&n=X_Zj60OJkr-kJxT1\&q=85\&s=e582a485f6775cbcc0fdfafbfd215752)

The modal lists every discount in the partner's group, with the group default marked and shown first. Select a different discount to override it for this partner.

![Discount selection](https://mintcdn.com/dub/X_Zj60OJkr-kJxT1/images/dub-partners/linklevel-discount-edit.png?fit=max\&auto=format\&n=X_Zj60OJkr-kJxT1\&q=85\&s=2e2ac1564b7bf74c48f43f998bb2a67e)

Before saving, you'll be asked to confirm the change and can add an optional note to the partner.

If the partner has [Stripe discount codes](#option-2-using-stripe-promo-codes-no-code-required), Dub automatically remaps their discount codes to the new discount so the customer-facing coupon matches what the partner advertises.

> [!NOTE]
>
> Partners with a partner-level discount are automatically excluded from any [group move rules](/help/article/partner-groups#group-move-rules), so they won't be accidentally moved to another group and lose their custom discount.

To override a reward for an individual partner instead, see [partner-level rewards](/help/article/partner-rewards#partner-level-rewards).

## Link-level discounts

Link-level discounts apply to one link only. They're useful when the same partner runs several campaigns with different customer offers, for example:

* A **limited-time promotion** with a deeper customer discount tied to one link only
* A **conference or event link** with a special attendee discount that shouldn't apply to the partner's other traffic
* A **product-specific landing page** where you want a different coupon than the partner's everyday links

Open the partner's details page from **All Partners**, then click the **Links** tab to see their referral links.

![Partner links tab](https://mintcdn.com/dub/X4WOJ2-QM5IGKP1O/images/dub-partners/create-reward-link.png?fit=max\&auto=format\&n=X4WOJ2-QM5IGKP1O\&q=85\&s=491656fd0349ecbb5ea4bf431564c442)

Click the `⋯` button and choose **Edit discount** for this selected link.

![Partner links dropdown](https://mintcdn.com/dub/X4WOJ2-QM5IGKP1O/images/dub-partners/create-reward-linklevel.png?fit=max\&auto=format\&n=X4WOJ2-QM5IGKP1O\&q=85\&s=0daabc873c968a566a8772709ad66bde)

The override modal works the same way as the partner-level one: pick an existing discount from the group, then confirm the change with an optional note to the partner.

> [!TIP]
>
> You can also set a link-level discount when you [create a link for a
> partner](/help/article/managing-program-partners#links). The **New partner
> link** modal has a discount selector.

If the partner has [Stripe discount codes](#option-2-using-stripe-promo-codes-no-code-required), Dub automatically remaps their discount codes to the new discount so the customer-facing coupon matches what the link advertises.

> [!NOTE]
>
> Partners with a link-level discount are automatically excluded from any [group move rules](/help/article/partner-groups#group-move-rules), so they won't be accidentally moved to another group and lose their custom discount.

To override a reward for a single link instead, see [link-level rewards](/help/article/partner-rewards#link-level-rewards).

### Override indicators

Partners with a discount override show a blue dot next to the icon. Click **Edit** to modify the override.

![Partner discount indicator](https://mintcdn.com/dub/X_Zj60OJkr-kJxT1/images/dub-partners/linklevel-reward-indicatorpartner.png?fit=max\&auto=format\&n=X_Zj60OJkr-kJxT1\&q=85\&s=843275375e0d2498826630a7aaf04a44)

Links with a link-level discount show an override icon next to the link name. Hover the icon to see that the discount is overridden, and click it to jump straight to the override modal.

![Link level indicator](https://mintcdn.com/dub/X_Zj60OJkr-kJxT1/images/dub-partners/linklevel-reward-indicatorlinks.png?fit=max\&auto=format\&n=X_Zj60OJkr-kJxT1\&q=85\&s=552d94c0c541602374e35206de8379e8)

### Removing an override

Open the override modal and select the **group** discount.

![Removing override](https://mintcdn.com/dub/X_Zj60OJkr-kJxT1/images/dub-partners/linklevel-reward-remove.png?fit=max\&auto=format\&n=X_Zj60OJkr-kJxT1\&q=85\&s=07f216f0f1007e8a132c080bae85c378)

Before deleting a discount that's used as an override, switch the affected partners or links back to the group discount or to another discount so they don't lose their customer offer.

### Partner discount view

Partners see their effective discount on their program **Overview** page in the partner dashboard, and can select from the dropdown to view their other links and associated discounts.

![Partner overview](https://mintcdn.com/dub/X_Zj60OJkr-kJxT1/images/dub-partners/linklevel-discount-partner-overview.png?fit=max\&auto=format\&n=X_Zj60OJkr-kJxT1\&q=85\&s=0b29fa62253a22308d6edccccb43f5de)

On their **Links** page, each link card shows the primary offer for that link, and a **+N** badge expands to show every reward and discount that applies to it, so partners always know which link offers what.

![Partner links](https://mintcdn.com/dub/X_Zj60OJkr-kJxT1/images/dub-partners/linklevel-discount-partner-links.png?fit=max\&auto=format\&n=X_Zj60OJkr-kJxT1\&q=85\&s=112d3683bdcea02076f4494ecb2bdc66)

When you change a partner-level or link-level discount, the partner also receives an email notification with the updated discount and any note you included.

### How overrides are resolved

When a customer is eligible for a discount, Dub picks the discount to apply in this order:

1. **Link-level discount** – The single link that triggered the event
2. **Partner-level discount** – Every link belonging to that partner
3. **Group discount** – Every partner in the group

Every partner-level and link-level discount change is recorded in the partner's activity log, including who made the change, the previous and new discount, the link it applied to (for link-level changes), and any note you added.

## 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](/docs/sdks/client-side/introduction) 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:

```json theme={null}
{
  "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
    "groupId": "grp_xxx", // unique ID of the group the partner belongs to
    "tenantId": "user_xxx" // partner's unique ID in your database
  },
  "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
    "couponId": "XZuejd0Q", // Stripe coupon code
    "couponTestId": "2NMXz81x" // Stripe test coupon ID
  }
}
```

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:

```javascript HTML theme={null}
// Display a banner that says: _"John referred you to Acme and gave you 25% off"_
dubAnalytics("ready", function () {
  if (DubAnalytics.partner && DubAnalytics.discount) {
    const banner = document.createElement("div");

    banner.innerHTML = `
      <div class="flex items-center gap-2">
        <img src="${DubAnalytics.partner.image}" alt="${DubAnalytics.partner.name}" class="size-6 rounded-full" />
        <p>${DubAnalytics.partner.name} referred you to Acme and gave you ${DubAnalytics.discount.amount} ${DubAnalytics.discount.type} off</p>
      </div>
    `;
    document.body.appendChild(banner);
  }
});
```

```typescript React/Next.js theme={null}
// Display a banner that says: _"John referred you to Acme and gave you 25% off"_
import { useAnalytics } from "@dub/analytics/react";

function DiscountBanner() {
  const { partner, discount } = useAnalytics();

  if (!partner || !discount) {
    return null;
  }

  return (
    <div className="flex items-center gap-2">
      <img
        src={partner.image}
        alt={partner.name}
        className="size-6 rounded-full"
      />
      <p>
        {partner.name} referred you to Acme and gave you {discount.amount}{" "}
        {discount.type} off
      </p>
    </div>
  );
}
```

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

![A screenshot of the Dub partner data example](https://mintcdn.com/dub/F9cdc9nB_SI4yl65/images/dub-partner-data.png?fit=max\&auto=format\&n=F9cdc9nB_SI4yl65\&q=85\&s=26eca59d43a93804f2307991c6c83381)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.