Docs

# Quotes and invoices

For a business that sells by quotation or invoice: record the referred buyer at the quote request, then each paid order, so its partner earns.

Most guides here assume a checkout that reports each payment. When you send quotes and invoices and get paid outside a checkout, the steps are:

1. The tracking script records the partner’s visit.
2. Your quote form records the buyer, by email.
3. You record each paid order. Affiligato matches it to the buyer by email and credits the partner.

## The tag records the visit

[Install the tracking script](https://affiligato.com/docs/tracking-script/) on every page of your site. When a visitor arrives through a partner’s link, the script records the click and keeps the referral in the `aff_ref` cookie on your domain for your program’s cookie window.

## The quote form records the buyer

When the buyer submits your quote or contact form, call `signup` with the email they typed:

```js
// In your quote form's submit handler:
await window.affiligato?.signup(form.email.value)
```

The buyer becomes the referral of the partner whose link brought them. A payment you record later for the same email pays that partner.

* `signup` sends only when the visitor holds a partner’s referral. For a visitor who came without a partner’s link, it sends nothing and returns `null`, so you can call it on every submission.
* It returns a promise. Wait for it before your form leaves the page, so the browser does not cancel the request.
* With `data-affiligato-consent="wait"`, the script stores nothing until your banner calls `window.affiligato.consent()`. Until then there is no referral to send, and a quote request made before the visitor accepts is not recorded. See [Cookies, consent and your security policy](https://affiligato.com/docs/tracking-script/#cookies-consent-and-your-security-policy).
* If your form posts to your own server, you can report the signup from there instead, with the partner code and click from the `aff_ref` cookie. See [Server-side integration](https://affiligato.com/docs/server-side/).

Use the email the invoice will go to. If the buyer pays from another address, record the payment with the email they used on the form.

## Partners can submit leads

A partner who brings a buyer some other way, by phone or by an introduction, can enter the buyer’s email in their portal when your program allows it.

* **Allow it** in **Settings → Joining → Partners can submit leads**, or with the agent tool `set_tracking {allowLeads: true}`. Partners then see **Submit a lead** on their Referrals page. Only approved partners can submit, and not while the program is paused. An email that is already a referral is refused.
* **Review them** with **Settings → Attribution → Review leads before they count**, or `leadReview: true` in `set_attribution`. A lead a partner submits then waits under **Customers** until you accept or reject it (the agent tools `list_leads` and `review_lead`). Review applies only to leads partners submit. A buyer the tag records with `signup` never waits for review.
* A payment recorded for a lead that is pending or rejected earns nothing: the transaction is kept as excluded. Accept the lead before you record its payment.

## The lead lifetime

The lead lifetime is how many days an unpaid referral stays its partner’s. It applies to every referral that has no payment, commission or trial yet, whether the tag recorded it or a partner submitted it. Past it, the lead expires, and a payment for it earns nothing.

Set it in **Settings → Attribution → Days until an unpaid lead expires**, or as `leadDays` in `set_attribution`. `0` means a lead never expires. Any other value is between your cookie window and 365 days. When a quote can take months to turn into an order, choose a long lifetime or `0`.

`set_attribution` takes all three settings in one call: `attribution` (`"first"` or `"last"`), `leadDays` and `leadReview`.

## Record each paid order

When an invoice is paid, record the payment. Affiligato finds the referral by the customer’s email, or by a customer id, and credits the partner through your commission rules, as it does a payment a billing provider reports.

| Where                     | How                                                                                                                                                                                                |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Dashboard, one payment    | **Transactions → Add payment**: the customer email, the amount (`49.00`), the currency, the date it was paid, and your invoice number as **Payment id**                                            |
| Agent, one payment        | `record_transaction`: `amount` in minor units (`4900` for 49.00), `currency`, `paidAt` as `YYYY-MM-DD`, the customer as `email` (or `customerId`), and your invoice number as `sourceId`           |
| Dashboard or agent, a CSV | **Transactions → Import CSV**, or `import_transactions_csv`. Columns: `id`, `customer_email` or `customer_id`, `amount` in major units (`49.00`), `currency`, `paid_at`, and optional `product_id` |

* A payment whose email matches no referral is recorded as unattributed and credits nobody.
* Give each payment your invoice number as its id. The same id is never recorded twice: **Add payment** and `record_transaction` refuse it, and the import skips the row as already recorded. A CSV row without an `id` gets a new one on every import, so importing the same file twice records those rows twice.
* A CSV import takes up to 5,000 rows. A row without a `currency` uses your program’s currency. Rows it skipped are listed with the reason.
* If an order is canceled after you recorded it, delete its transaction under **Transactions** (or `remove_transaction`) to reverse its unpaid commission.

## Tell setup that you record payments by hand

With no billing provider connected, the setup checklist cannot tell that payments will arrive. Say that you record them by hand: in **Settings → Connect → Conversion settings**, turn on **We record payments by hand**, or call `set_conversions {paymentsByHand: true}`. The setup checklist, `setup_plan` and `go_live` then count billing as done.

A working HubSpot, Salesforce or Attio connection counts billing as done too, since a won deal or opportunity pays the commission.

## If your deals live in a CRM

If you track quotes as deals in HubSpot or Attio, or as opportunities in Salesforce, a won one can pay the commission instead of a payment you record by hand. Referred buyers also appear in the CRM with the partner who sent them. See [HubSpot](https://affiligato.com/docs/hubspot/), [Salesforce](https://affiligato.com/docs/salesforce/) and [Attio](https://affiligato.com/docs/attio/).

If buyers book a call or a demo before they ask for a quote, a Calendly or Cal.com booking can record the buyer for you. See [Calendly and Cal.com](https://affiligato.com/docs/bookings/).
