Get Product Performance Data

This API returns the number of users who viewed and purchased one or more products over different time periods. This enables you to create custom use cases that leverage this data, whether for display or other use cases.

πŸ“Œ

Native alternatives to the API

  • The Product Performance template variable lets you display product performance data inside Dynamic Yield campaigns. For example, a notification on a product page with the number of unique users who purchased it in the past 24 hours. Product performance is shown at the group ID level and not the SKU level.
  • The Product Popularity targeting condition enables you to target experiences based on the performance of the product page. For example, show a "Popular product" badge only on products that were purchased by at least X unique users in the past week.

Enabling the API

To enable the API, go to Settings β€Ί General Settings β€Ί Product Performance API, and click Enable. You need Admin permissions.

Setting product properties

When the API is enabled, product views and purchases are returned in the API response. If you also want to retrieve product properties, you can list up to 15 properties to get data for.

Click Select Product Properties, and in the dialog, select the properties you want to include in the API call.

These properties are retrieved when the attribute includeProductData is set to "true". If the attribute is set to "false", you retrieve only product views and purchases, no product data.

🚧

If your business use case isn't fully supported by the limitations of this feature, contact your Technical Account Manager.

API parameters

Syntax:

function getProductsData(skus, timeframes, includeProductInterest, includeProductData, callback)
ParameterDescription
skusSyntax: List[String].
An array of up to 20 product SKUs.
timeframesSyntax: List[String]. An array of one or more values defining the timeframe going back. If undefined, returns values for all time periods. The values can be:
* daily (last 24 hours)
* twoDays (last 48 hours)
* weekly (last 168 hours)
* twoWeeks (last 336 hours)
* monthly (last 720 hours)
includeProductInterestDetermines if viewing data, purchase data, or both are returned. If undefined, both are returned. The values can be:
* View
* Purchase
includeProductDataDetermines whether or not to display product attributes and details such as color, style, and so on. The values can be true or false. Note that only listed product properties are returned in the API.
callbackThe callback function.

Call example:

DY.ServerUtil.getProductsData(["1217282-400", "1217282-600"], ['daily', 'twoDays'], 'view', false, function(err, res) { console.log(res)})

Response example:

{
  "1217282-400": {
    "productInterest": {
      "view": {
        "daily": 1,
        "twoDays": 1
      },
      "city": {
        "view": {},
        "purchase": {}
      }
    }
  },
  "1217282-600": {
    "productInterest": {
      "view": {
        "daily": 1,
        "twoDays": 1
      },
      "city": {
        "view": {},
        "purchase": {}
      }
    }
  }
}