# Awin

[Awin](https://www.awin.com/) is an affiliate marketing program that connects advertisers and affiliates of all sizes. It provides a network of affiliate partners, click tracing and tracking, advertiser directory, reports and analytics, and more.

Find the open source code for this destination in the [GitHub repository](https://github.com/rudderlabs/rudder-transformer/tree/main/src/v0/destinations/awin).

## Connection compatibility

{{< destination-config >}}

## Get started

Once you have confirmed that the source platform supports sending events to Awin, follow these steps:

1. From your [RudderStack dashboard](https://app.rudderstack.com/), add a source. Then, from the list of destinations, select **Awin**.
2. Assign a name to the destination and click **Continue**.

## Connection settings

To successfully set up Awin as a destination, you will need to configure the following settings:

- **Advertiser ID**: Enter your [Awin advertiser ID](#faq).
- **Events to Track**: Enter the event names for which you want to track the conversions. 

{{< warning >}}
You must enter all event names for which you want to make a `track` call.
{{< /warning >}}

- **Map Rudder payload property to custom Awin field**: Enter the RudderStack property and the corresponding Awin custom field you want to map together. These custom properties get associated to a specific transaction and sent to Awin for `track` calls. The Awin field names must follow the `p<int>` format (like `p1`, `p2`, etc.). RudderStack picks the field values from `message.properties` and sends them as query parameters.

{{< warning >}}
Duplicate mapping can cause errors.
{{< /warning >}}

## Track

You can use the [`track`]({{< ref "event-spec/standard-events/track.md" >}}) call to [send the conversion data directly to Awin's servers](https://wiki.awin.com/index.php/Advertiser_Tracking_Guide/Conversion_Pixel_Only_Tracking#Server_To_Server_.28S2S.29).

A sample `track` call is shown below:

```javascript
rudderanalytics.track("Product Purchased New", {
  revenue: 4.99,
  currency: "USD",
  commissionGroup: "CD",
  name: "Shirt",
  voucherCode: "FIRSTSALE",
  order_id: "ORD123",
});
```

### Supported mappings

The following table lists the mappings between the RudderStack and Awin properties:

#### **Product-level tracking**

| RudderStack property | Awin property | 
| :--------------| :---------| 
| `properties.order_id`<br/>`properties.orderId` <br/> `properties.orderReference` <br/> `properties.order_reference` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `orderReference` |
| `product[i].product_id` <br /> `product[i].productId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `productId` |
| `properties.products[i].name` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `productName` |
| `properties.products[i].price` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `productItemPrice` |
| `properties.products[i].quantity` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `productQuantity` |
| `properties.commissionGroup`<br/> `properties.commission_group` <br/> <span style="color: #4D4DFF;font-size:12px;">Required. Default value is `DEFAULT`</span> | `commissionGroupCode` |
| `properties.products[i].sku` <br/> <span style="color: #4D4DFF;font-size:12px;">Optional. If not present, RudderStack sends an empty value instead. </span>  |  `productSku` | 
| `properties.products[i].category` <br/> <span style="color: #4D4DFF;font-size:12px;">Optional. If not present, RudderStack sends an empty value instead. </span>  | `productCategory` |

#### **Other mappings**

| RudderStack property | Awin property | 
| :--------------| :---------| 
| `properties.revenue` <br/> `properties.totalAmount` <br/> `properties.amount` <br/> `properties.total_amount` | `totalAmount` | 
| `properties.voucherCode`<br/> `properties.voucher_code`  | `voucher_code` | 
| `properties.currency` <br/> `properties.currencyCode` <br/> `properties.currency_code` | `currencyCode` |
| `properties.cks`<br/> `properties.awc`  | `awc` |
| `properties.testMode` <br/> `properties.test_mode` <br/> `properties.isTest`<br/> `properties.is_test` <br/> <span style="color: #4D4DFF;font-size:12px;">Default value is `0`. </span> | `isTest`  |

## FAQ 

#### Where can I find the Awin advertiser ID?

To obtain your Awin advertiser ID, log in to your [Awin dashboard](https://ui.awin.com/idp/en/awin/login) to see the advertiser ID in the top right corner as well as in the URL:

{{< image src="images/event-stream-destinations/advertiser-id-awin.webp" alt="Awin advertiser ID" >}}

