# Topsort Cloud Mode Integration

After you have successfully instrumented Topsort as a destination in RudderStack, follow this guide to correctly send your events to Topsort in [cloud mode]({{< ref "/destinations/rudderstack-connection-modes.md#cloud-mode" >}}).

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

## Track

You can use the [`track`]({{< ref "event-spec/standard-events/track.md" >}}) call to capture user events along with the associated properties and send them to Topsort.

A sample `track` call is shown:

```javascript
rudderanalytics.track("Product Added", {
  product_id: "9578257311",
  sku: "8472-998-0112",
  name: "Sample Product"
})
```

### Default event mappings

By default, RudderStack maps the following [ecommerce events]({{< ref "event-spec/ecommerce-events-spec/" >}}) to the corresponding Topsort events:

| RudderStack event | Topsort event | 
| :----| :------|
| `Order Completed`  | `purchases` | 
| `Product Clicked` <br /> `Product Added`  | `clicks` |
| `Product Viewed` <br /> `Product List Viewed`  |  `impressions` | 

Note that you can change these mappings in the RudderStack dashboard using the [Event mapping settings]({{< ref "destinations/streaming-destinations/topsort/setup-guide.md#event-mapping-settings" >}}).

### Purchases event mappings

RudderStack maps the following `track` event properties to the corresponding Topsort `purchases` event properties:

| RudderStack property | Data type |  Topsort property | 
| :----| :------| :----|
| `messageId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required <br />Automatically added by RudderStack in the final event payload.</span> | String | `id` |  
| `timestamp` <br /> `originalTimestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required <br />Automatically added by RudderStack in the final event payload. </span> | Datetime |  `occuredAt` | 
| `anonymousId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | String |  `opaqueUserId` | 
| `products` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> |  Object |  [`Items`](#items-object-mappings) |

#### `Items` object mappings

| RudderStack property | Data type | Topsort property | 
| :----| :------| :----|
| `products.$.product_id` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span>  | String | `productId` | 
| `products.$.price` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | Number | `unitPrice` | 
| `products.$.quantity` | Integer |  `quantity` | 
| `products.$.vendorId` | String |  `vendorId` | 

### Impressions event mappings

RudderStack maps the following `track` event properties to the corresponding Topsort `impressions` event properties:

| RudderStack property | Data type | Topsort property |
| :----| :------| :----|
| `messageId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required <br />Automatically added by RudderStack in the final event payload.</span> | String | `id` |  
| `timestamp` <br /> `originalTimestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required <br />Automatically added by RudderStack in the final event payload. </span> | Datetime |  `occuredAt` | 
| `anonymousId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | String |  `opaqueUserId` | 
| `properties.resolvedBidId` | String | `resolvedBidId` | 
| `properties.entity` | Object |  `entity` | 
| `properties.additionalAttribution` |  Object |  `additionalAttribution` |
| `properties.placement` | Object |  [`placement`](#placement-object-mappings) | 

#### `placement` object mappings

| RudderStack property | Data type | Topsort property |
| :----| :------| :----|
| `context.page.path`<br/> <span style="color: #4D4DFF;font-size:12px;">Required</span>  | String |  `path` | 
| `properties.position` | Integer |  `position` | 
| `properties.product_id` | String |  `productId` | 
| `properties.query` | String |  `searchQuery` | 
| `properties.pageNumber` | Integer | `page` | 
| `properties.pageSize` | Integer | `pageSize` | 
| [`properties.category_id`] | Array |  `categoryIds` | 

### Clicks event mappings

RudderStack maps the following `track` event properties to the corresponding Topsort `clicks` event properties:

| RudderStack property | Data type | Topsort property | 
| :----| :------| :----|
| `messageId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required <br />Automatically added by RudderStack in the final event payload.</span> | String | `id` |  
| `timestamp` <br /> `originalTimestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required <br />Automatically added by RudderStack in the final event payload. </span> | Datetime |  `occuredAt` | 
| `anonymousId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> |  String |  `opaqueUserId` |
| `properties.resolvedBidId` | String | `resolvedBidId` | 
| `properties.entity` | Object | `entity` |  
| `properties.additionalAttribution` | Object |  `additionalAttribution` | 
| `properties.placement` | Object |  [`placement`](#placement-object-mappings-1) | 

#### `placement` object mappings

| RudderStack property | Data type | Topsort property | 
| :----| :------| :----|
| `context.page.path`<br/> <span style="color: #4D4DFF;font-size:12px;">Required</span>  | String |  `path` | 
| `properties.position` | Integer |  `position` | 
| `properties.product_id` | String |  `productId` | 
| `properties.query` | String |  `searchQuery` | 
| `properties.pageNumber` | Integer | `page` | 
| `properties.pageSize` | Integer | `pageSize` | 
| [`properties.category_id`] | Array |  `categoryIds` | 
