> For the complete documentation index, see [llms.txt](https://help.dollarlabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.dollarlabs.io/dollarback-store-credit/referral-program/how-referral-rewards-are-calculated-and-tracked.md).

# How referral rewards are calculated & tracked

{% embed url="<https://dollarlabs.neetorecord.com/watch/afb2392f20194ecc04cb>" %}

*This article's section starts at 1:57 in the video.*

This is the reference for the referral engine: how DollarBack decides an order was referred, how much the referrer earns, in which currency, and what happens on refunds and edits. If a referral reward looks wrong, the answer is almost always on this page.

## Attribution: the code must be on the order

A referral counts only when the referee's order used the referrer's discount code. There is no cookie or link-only attribution: sharing a link starts the journey, but if the code isn't applied on the order, no referral is recorded.

* Each customer's referral code is stored on their customer profile in the `db-referral.code` metafield.
* Legacy programs used the customer's numeric ID as the code; those all-digit codes still attribute correctly.
* When an order comes in with a referral code, DollarBack looks up which customer owns that code; that customer is the referrer.

**One reward per referee order.** Processing is idempotent on the referee's order ID, so replays, webhook retries, or reprocessing can never double-pay a referral.

## Which config applies: referrer tags, in priority order

If you run more than one config, DollarBack walks your configs top-to-bottom (the drag-and-drop order on the Referral page) and picks the **first config whose Customer Tags match the referrer**. A config with no tags matches everyone. The winning config dictates the reward type and value, and the reward's expiry. See [Run multiple referral configs](/dollarback-store-credit/referral-program/run-multiple-referral-configs.md).

## The reward base: what a percentage is a percentage *of*

The referral reward base mirrors your global cashback settings ([Settings](/dollarback-store-credit/settings.md)):

1. Start from the **order total or subtotal**, per your **Base cashback on** setting, adding or removing **shipping** per the **Include shipping costs** toggle.
2. **Deduct the portions paid with store credit and gift cards**, per the same global settings that govern cashback (**Pays with store credit** / **Pays with gift cards**).
3. If store credit plus gift cards cover the **whole** order, the referral reward is **skipped entirely**: no referrer credit is issued for an order with no real money in it.
4. Apply the config's reward: percentage of the remaining base, or the fixed amount.
5. Cap the result at your **Maximum cashback per order** ceiling (from global settings, converted into the order's currency). Fixed rewards are clamped by the same ceiling.

### Worked example

Referee's order: $80 subtotal + $10 shipping. They pay $20 with a gift card. Settings: base on subtotal, shipping excluded, gift-card portion doesn't earn. Referrer reward: 10%.

* Base: $80 (subtotal, no shipping)
* Minus gift-card portion: $80 − $20 = $60
* Reward: 10% × $60 = **$6.00** store credit, unless your max-cashback ceiling is lower.

## Currency: the referrer earns in their own currency

The reward is converted into the **referrer's** currency using current exchange rates. A referrer whose account is in USD earns USD credit even if the referee paid in EUR. Cross-market referrals work automatically, and two referrers can earn different-looking amounts from identical orders.

## Refunds, cancellations, and order edits

When the referee's order changes, the reward is **recomputed as a diff** against what was already granted:

* **Negative diff** (refund, cancellation, downsized edit): the difference is **clawed back**: the referrer's balance is debited.
* **Positive diff** (order edited upward): the difference is issued as **pending credit**.
* **Pending referral credits release** when the order's payment is captured or it's fulfilled.
* The full referral history is stored on the order, so the audit trail in the logs always reconciles.

{% hint style="warning" %}
Clawbacks debit the referrer's live balance. If they've already spent the credit, their balance can go into deficit until they earn more.
{% endhint %}

## Where to see it all

**DollarBack admin → Analytics → Referral** shows revenue, orders, active affiliates, and commissions, plus a log linking each referral to the referrer, the referee, and the Shopify order. See [Referral analytics](/dollarback-store-credit/analytics-data-and-account/referral-analytics.md).

## Verify it works

Place a test order with a referral code as a new customer, in a different currency market if you have one. In the referral analytics log, confirm the row links both profiles and the order, and that the commission equals the expected percentage of the deducted base, converted to the referrer's currency.

## Common issues

* No reward recorded → was the code actually on the order? Link sharing alone doesn't attribute; see [A referral wasn't tracked](/dollarback-store-credit/troubleshooting-and-faq/referral-wasnt-tracked.md).
* Reward smaller than expected → credit/gift-card deductions, subtotal-vs-total base, or the max-cashback ceiling.
* Reward is $0 → the order was fully paid with store credit and/or gift cards, so the reward was skipped.
* Reward appeared, then a debit → the referee's order was refunded, cancelled, or edited down; see [Refunds, cancellations & order edits](/dollarback-store-credit/spending-store-credit-and-rewards/refunds-cancellations-and-order-edits.md).

## Related articles

* [Referrer rewards vs referee discounts](/dollarback-store-credit/referral-program/referrer-rewards-vs-referee-discounts.md)
* [Run multiple referral configs](/dollarback-store-credit/referral-program/run-multiple-referral-configs.md)
* [Settings](/dollarback-store-credit/settings.md)
* [Referral analytics](/dollarback-store-credit/analytics-data-and-account/referral-analytics.md)
