Track Purchases

You can use the OnlineSales.ai pixel to track the visitors actions like a PurchaseTracked product purchases are used to compute the sales score, user's affinity to product, user's spend capacity and other signals which helps in measurement & optimising the campaigns.

Requirements

The pixel's base code must already be installed on every page where you want to track conversions.

Trigger

purchase event should be fired when a user completes the purchase of the product. i.e. after the payment is successful and the order id is generated.

JS API

All events are tracked by calling one of the library's function with a JSON object as it's parameters.

Following is a function call to track when a visitor views cart on your website.

// with minimum required parameters
_osSaleComplete({
    "products": [{
        "skuId": "XYZ-1231-1233",
        "sellerId": "SID-9999",
        "productPrice": "899",
        "quantity": "2" // optional. Defaults to 1
    },{
        "skuId": "ABC-1231-1233",
        "sellerId": "XID-123123",
        "productPrice": "99",
    }],
    "totalAmount": "998",
    "currency": "INR",
    "orderId": "OR-94716273-S",
    "cli_ubid": "ubid-83789ssb"
}) 

This function takes the same parameters as the _osViewCart The only different is ViewCart event is fired on the load of cart page and _osCheckout is fired on a button click (which initiates the billing & payment process) of the cart page.

List of all the standard events can be found here.

Object Properties of Products key

You can include the following predefined object properties with any events that support them. Format your parameter object data using JSON.

Property Key

Parameter Description

category

Category of the menu item. This should be the same as what is given in the menu item catalog. While this is optional, this parameter is highly recommended.

productPrice

Price of single menu item without the currency symbol

currency

Currency of the menu item's price. Eg: "INR". This should be a 3 letter ISO standard

discount

Discounted price of single menu item

skuId

The id of the menu item. This should be the same as what is given in the menu item catalog. This is a mandatory parameter.

sellerId

The id of the restaurant who is selling this menu item. This is mandatory in case of aggregators.

quantity

Number of product quantity added to the cart. This is optional and defaults to 1

totalAmount

Total cart amount. Sum of all the menu item's prices. This may include taxes / discounts in case of saleComplete event.

orderId

The order id which is generated and shown to the users on the website.

paymentMethod

The payment method used to complete the transaction

cli_ubid

Client generated user id. If set, this takes precedence over ubid passed in the cookie. Once generated for a user, it should be same for all the API calls.

Complete list of object properties can be found here.

Example call of function with all the product properties

// with all parameters
_osSaleComplete({
    "products": [{
        "skuId": "XYZ-1231-1233",
        "sellerId": "SID-9999",
        "category": "Pizza > Veg Pizza",
        "productPrice": "999", // price of single product
        "currency": "INR",
        "discount": "899", // discounted price of single product
        "quantity": "2"
    },{
        "skuId": "ABC-1231-1233",
        "sellerId": "XID-123123",
        "category": "Pizza > Veg Pizza",
        "productPrice": "999", // price of single product
        "currency": "INR",
        "discount": "899", // discounted price of single product
        "quantity": "2"
    }],
    "totalAmount": "3596",
    "currency": "INR",
    "orderId": "OR-94716273-S",
    "paymentMethod": "CreditCard",
    "cli_ubid": "ubid-83789ssb"
})

Last updated