# Affiliatly Destination

> Send completed orders and order status changes to Affiliatly so the right affiliate earns commission on every sale they refer.

Source: https://docs.oursprivacy.com/docs/affiliatly

Use this page to connect Ours Privacy to **Affiliatly** and send your store's orders to your affiliate program, so each referred sale is credited to the affiliate who drove it and refunds or cancellations update their commission.

***

## Before you start

* An Affiliatly account for your store.
* Your **Affiliatly Code** and **Security Hash** from the Affiliatly admin panel.
* Affiliatly's tracking script installed on your site, and the [Ours Privacy Web SDK](https://docs.oursprivacy.com/docs/web-sdk-javascript) on the same pages.
* A completed-purchase event that carries a unique order ID and the order total.

## Setup

1. In Affiliatly, open **Account** and copy **Your Affiliatly Code**. It looks like `AF-10XXXXX`.
2. On the same **Account** page, copy your **Security Hash**.
3. In Ours Privacy, open [Destinations](https://app.oursprivacy.com/destinations), add **Affiliatly**, and paste the values into **Account Code** and **Security Hash**.
4. Connect your completed-purchase event and set the mapping's **Action** to **Record Purchase**. Map a stable **Order ID** and the order **Price**.
5. Connect your refund and cancellation events and set **Action** to **Update Order Status**, with the same **Order ID** and the matching **Order Status**.
6. Publish your changes, then place a test order from a visit that starts with `?aff=1` on your store's URL and confirm it appears in your Affiliatly dashboard.

If you generate a new Security Hash in Affiliatly, update it in Ours Privacy too.

## How orders are credited

Affiliatly credits an order to an affiliate in any of three ways:

* **Affiliate link visit.** A visitor arrives through an affiliate's link. Keep Affiliatly's tracking script on your site so Affiliatly recognizes these visitors when they come back to buy.
* **Coupon code.** The customer uses a coupon assigned to an affiliate. Map **Coupon Code** to credit these orders even without a link visit.
* **Customer email.** The customer's email matches one Affiliatly already links to an affiliate. Turn on tracking by email in Affiliatly, then map **Customer Email**.

Orders that match none of these are not sent, because Affiliatly has no affiliate to credit.

## Recommended event setup

* **Completed purchase:** **Record Purchase**. Send it once per order.
* **Refunded or cancelled order:** **Update Order Status** with **Refunded** or **Cancelled**. This stops the affiliate's commission on the original order. Never send a second **Record Purchase** for a refund.
* **Order later marked paid or fulfilled:** **Update Order Status** with **Paid**, if your Affiliatly program waits for payment before approving commission.

## A note on order values

* Send the order total without shipping, in your store's default currency in Affiliatly, so commissions are calculated on the right amount.
* Partial refunds are not adjusted automatically. Review the order's commission in Affiliatly when you refund part of an order.

***

## Next steps

* [Configure event mappings](https://docs.oursprivacy.com/docs/data-mapping)
* [Destinations overview](https://docs.oursprivacy.com/docs/destination-overview)
* [Affiliatly help center](https://affiliatly.helpscoutdocs.com/)

## Need help?

Contact [support@oursprivacy.com](mailto:support@oursprivacy.com).
