# Transactions

Transactions are events which relate to the sale of products and services. Generally, these include Orders and Cancellations / Returns. These events are key, as revenue is generated here, and are vital for Modelling and Predictions.

### Events

| Event                | Description                      |
| -------------------- | -------------------------------- |
| Completed Order      | An order is placed               |
| Changed Order Status | An order is cancelled / returned |

For contractual businesses, CrossEngage also has the following events:

<table><thead><tr><th width="211.5">Event</th><th>Description</th></tr></thead><tbody><tr><td>contract_sale</td><td>Conclusion of a contract</td></tr><tr><td>contract_start</td><td>start of the contract</td></tr><tr><td>contract_cancellation</td><td>The contract is cancelled</td></tr><tr><td>contract_end</td><td>The contact expires</td></tr><tr><td>contract_return</td><td>the contract is cancelled during trial phase</td></tr></tbody></table>

### Properties

Order events have three base properties, as well as Cart properties. Cart properties can be accessed by using cart.products\[***product\_number***].***property.***

<table><thead><tr><th width="234">Property</th><th>Description</th><th width="108" data-type="checkbox">Mandatory</th><th>Example</th></tr></thead><tbody><tr><td>id</td><td>Unique Identifier</td><td>true</td><td>DEF12345</td></tr><tr><td>timestamp</td><td>Event date</td><td>true</td><td>2022-01-01</td></tr><tr><td>orderId</td><td>Invoice ID</td><td>true</td><td>1234</td></tr><tr><td>cart.products[].id</td><td>Invoice item number</td><td>true</td><td>1</td></tr><tr><td>cart.products[].quantity</td><td>quantity of item</td><td>true</td><td>4</td></tr><tr><td>cart.products[].price</td><td>price per unit</td><td>true</td><td>10.99</td></tr><tr><td>cart.products[].category</td><td>Product Category</td><td>false</td><td>Shoes</td></tr><tr><td>cart.product[].brand</td><td>Product brand</td><td>false</td><td>Samsung</td></tr><tr><td>cart.products[].sku</td><td>Product SKU</td><td>false</td><td>AB1234</td></tr><tr><td>cart.products[].name</td><td>Product name</td><td>false</td><td>Cap</td></tr><tr><td>cart.currency</td><td>Currency of payment</td><td>false</td><td>Euro</td></tr></tbody></table>

### Examples

You can upload these events using the CrossEngage API, or via the Event Feed. Please go to [Data Management ](https://documentation.crossengage.io/data-and-engagement-platform/data-management)to learn more.

Here is an example of the JSON used to upload two events via the API.

```javascript
{
  "id": "ABC12345",
  "events": [{
          "event": "Completed Order",
          "timestamp": "2022-01-01T09:21:06Z",
          "properties": {
              "orderId": "1234",
              "cart": {
                  "total": 46.13,
                  "currency": "EUR",
                  "numberOfItems": 3,
                  "numberOfUniqueItems": 2,
                  "products": [{
                          "id": "1",
                          "price": 10.99,
                          "quantity": 1,
                          "category": "T-shirt"
                  },{
                          "id": "2",
                          "price": 17.57,
                          "quantity": 2,
                          "category": "Shoe"
                  }]
              }
          }
        }, {
          "event": "Changed Order Status",
          "timestamp": "2022-01-01T09:21:06Z",
          "properties": {
              "orderId": "1234",
              “status”: “return”,
              "currency": "EUR",
              “id”: “1”,
              "price": 10.99,
              "quantity": 1,
              "category": "T-shirt"
	  }
	}]
}
```

Here is the same example, presented as a JSON file that can be uploaded via Data Feeds:

```javascript
[{
   "event": "Completed Order",
   "id": "ABC12345",
   "timestamp": "2022-01-01T09:21:06Z",
   "orderId": "1234",
   "cart": {
       "total": 46.13,
       "currency": "EUR",
       "numberOfItems": 3,
       "numberOfUniqueItems": 2,
       "products": [{
               "id": "1",
               "price": 10.99,
               "quantity": 1,
               "category": "T-shirt"
           },
           {
               "id": "2",
               "price": 17.57,
               "quantity": 2,
               "category": "Shoe"
           }]}}
{
   "event": "Changed Order Status",
   "id": "ABC12345",
   "timestamp": "2022-01-01T09:21:06Z",
   "orderId": "1234",
   “status”: “return”,
   "currency": "EUR", 
    “id”: “1”,
   "price": 10.99,
   "quantity": 1,
   "category": "T-shirt"
}]
```
