> For the complete documentation index, see [llms.txt](https://docs.saleassist.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.saleassist.ai/integration-guide/sales-conversion-tracking-widget.md).

# Sales/Conversion Tracking - Widget

<figure><img src="/files/yXT0UCysxbnZ7ofoRNHN" alt="" width="128"><figcaption><p>Sales Conversion Tracking</p></figcaption></figure>

‘**saleassist.track**’ Function Documentation

**Description**

The eventCaller function is a utility function in JavaScript that allows you to trigger custom events with specific data. It takes an event name as a string and an optional data object as parameters. When called, the **saleassist.track** function dispatches a custom event with the given name and the provided data, making it possible to capture custom events in your JavaScript applications.

**Parameters**

* eventName (String): The name of the custom event to be dispatched. It should be a string representing the event's name.
* data (Objectl): An data object to be passed along with the custom event. This data can be used by event listeners to access additional information related to the event.

**Usage**

Here's an example of how to use the **saleassist.track** function for **Product Click**:

```javascript
// Example: Triggering an event with data
const eventData = {
        'view_data' : {
        'url': "https://someurl.com"
        },
        'actionField': {'list': 'Search Results'}, // Optional list property.
        'products': [{
          'name': productObj.name,   // Name or ID is required.
          'id': productObj.id,
          'price': productObj.price,
          'brand': productObj.brand,
          'category': productObj.cat,
          'variant': productObj.variant,
          'position': productObj.position
        }]
    };

saleassist.track("productClick", eventData, [widgetID_1 , widgetID_2])
saleassistVideoTiles.track("productClick", eventData, [playlistID_1 , playlistID_2])
```

Here's an example of how to use the **saleassist.track** function for **Product Detail**:

```javascript
// Example: Triggering an event with data
const eventData = {
    'view_data' : {
        'url': "https://someurl.com"
        },
      'actionField': {'list': 'Apparel Gallery'},    // 'detail' actions have an optional list property.
      'products': [{
        'name': 'Triblend Android T-Shirt',         // Name or ID is required.
        'id': '12345',
        'price': '15.25',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Gray'
      }]
    };

saleassist.track("productDetail", eventData, [widgetID_1 , widgetID_2]);
saleassistVideoTiles.track("productDetail", eventData, [playlistID_1 , playlistID_2])
```

Here's an example of how to use the **saleassist.track** function for **Add To Cart**:

```javascript
// Example: Triggering an event with data
const eventData = {
    'view_data' : {
        'url': "https://someurl.com"
        },
    'currencyCode': 'EUR', 
    'actionField': {'id': 'product id'},        // 'add' actionFieldObject measures.
      'products': [{                        //  adding a product to a shopping cart.
        'name': 'Triblend Android T-Shirt',
        'id': '12345',
        'price': '15.25',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Gray',
        'quantity': 1
      }]
  };

saleassist.track("addToCart", eventData, [widgetID_1 , widgetID_2]);
saleassistVideoTiles.track("addToCart", eventData, [playlistID_1 , playlistID_2])
```

Here's an example of how to use the **saleassist.track** function for **Promotion Clicks**:

```javascript
// Example: Triggering an event with data
const eventData = {
    'view_data' : {
        'url': "https://someurl.com"
        },
      'promotions': [                     // Array of promoFieldObjects.
      {
        'id': 'JUNE_PROMO13',            // ID or Name is required.
        'name': 'June Sale',
        'creative': 'banner1',
        'position': 'slot1'
      }]
    };

saleassist.track("promotionClick", eventData, [widgetID_1 , widgetID_2]);
saleassistVideoTiles.track("promotionClick", eventData, [playlistID_1 , playlistID_2])
```

Here's an example of how to use the **saleassist.track** function for **Checkout**:

```javascript
// Example: Triggering an event with data
const eventData ={
    'view_data' : {
        'url': "https://someurl.com"
        },
        'actionField': {'step': 1, 'option': 'Visa'},
        'products': [{
          'name': 'Triblend Android T-Shirt',
          'id': '12345',
          'price': '15.25',
          'brand': 'Google',
          'category': 'Apparel',
          'variant': 'Gray',
          'quantity': 1
      }]
    };

saleassist.track("checkout", eventData, [widgetID_1 , widgetID_2]);
saleassistVideoTiles.track("checkout", eventData, [playlistID_1 , playlistID_2])
```

Here's an example of how to use the **saleassist.track** function for **Page View**:

```javascript
// Example: triggering an event with data

const eventData = {
    'actionField': {'id': 'T12345'},
    'view_data' = {
        'url': "https://someurl.com"
    }
}
// Track view event
saleassist.track( page_view , eventData , [widgetID_1 , widgetID_2] )
```

Here's an example of how to use the **saleassist.track** function for **Measuring Purchases**:

```javascript
// Example: Triggering an event with data
const eventData ={
    'view_data' : {
        'url': "https://someurl.com"
        },
      'actionField': {
        'id': 'T12345', // Transaction ID. Required for purchases and refunds.
        'affiliation': 'Online Store',
        'revenue': '35.43', // Total transaction value (incl. tax and shipping)
        'tax':'4.90',
        'shipping': '5.99',
        'coupon': 'SUMMER_SALE'
      },
      'products': [{       // List of productFieldObjects.
        'name': 'Triblend Android T-Shirt',  // Name or ID is required.
        'id': '12345',
        'price': '15.25',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Gray',
        'quantity': 1,
        'coupon': ''  // Optional fields may be omitted or set to empty string.
      },
      {
        'name': 'Donut Friday Scented T-Shirt',
        'id': '67890',
        'price': '33.75',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Black',
        'quantity': 1
      }]
    };

saleassist.track("purchase", eventData, [widgetID_1 , widgetID_2]);
saleassistVideoTiles.track("purchase", eventData, [playlistID_1 , playlistID_2])
```

Here's an example of how to use the **saleassist.track** function for **Measuring Refunds**:

```javascript
// Example: Triggering an event with data
const eventData ={
    'view_data' : {
        'url': "https://someurl.com"
        },
      'actionField': {'id': 'T12345'}         // Transaction ID. Required for purchases and refunds.
    };

saleassist.track("refund", eventData, [widgetID_1 , widgetID_2]);
saleassistVideoTiles.track("refund", eventData, [playlistID_1 , playlistID_2])
```

Here's an example of how to use the **saleassist.track** function for Partial Refunds:

```javascript
// Example: Triggering an event with data
const eventData ={
    'view_data' : {
        'url': "https://someurl.com"
        },
      'actionField': {'id': 'T12345'},        // Transaction ID.
      'products': [
            {'id': 'P4567', 'quantity': 1},   // Product ID and quantity. Required for partial refunds.
            {'id': 'P8901','quantity': 2}
      ]
    };

saleassist.track("refund", eventData, [widgetID_1 , widgetID_2]);
saleassistVideoTiles.track("refund", eventData, [playlistID_1 , playlistID_2])
```

\
**Questions?**

Please feel free to reach out via <mark style="color:blue;"><support@saleassist.ai></mark> if you need any help.
