Track Product View

You can use the OnlineSales.ai pixel to track your website visitors' product view action. Tracked product views are used to compute the popularity score, user's affinity, and other signals.

Requirements

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

Trigger

Product View event should be fired when a user visits a product page.

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 has viewed a product on the website:

// with minimum required parameters
_osViewProduct({
    "cli_ubid": "ubid-83789ssb",
    "products": [{
        "skuId": "XYZ-1231-1233",
        "sellerId": "SID-9999"
    }]
})

A 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.

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 the menu item without the currency symbol

currency

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

discount

Discounted price of the 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 the case of aggregators.

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.

A complete list of object properties can be found here.

An example call of a function with all the product properties:

// with all parameters
_osViewProduct({
    "products": [{
        "skuId": "XYZ-1231-1233",
        "sellerId": "SID-9999",
        "category": "Pizza > Veg Pizza",
        "productPrice": "999",
        "currency": "INR",
        "discount": "899"
    }],
    "cli_ubid": "ubid-83789ssb"
})

Last updated