NAV
cURL Javascript

Product Recommendation API

Introduction

This documentation aims at explaining how AB Tasty’s product recommendation API works, how to use it and how to implement it.

Transactional context

The API can returns recommended products based on the purchases history of all visitors. Correlations are made between the list of items bought by one visitor and all the product pages he has seen before buying. With sufficient amount of data, the recommendation engine can decide which set of items should be displayed as a recommendation for a specific product page.

Prerequesites

Usage flow

The usage of this API consists on two main things:

  1. sending the adequate data to the engine through the API
  2. getting the appropriate results to display and render the list

1. Sending the adequate data

window.abtasty.send("EVENT", {
    ec: "Product Recommendation",
    ea: "13EA45",
    el: "http://www.website.com/resources/13EA45.jpg",
    ev: 13.37,
    cd: {
      "1": 1586960579,
      "2": "http://www.website.com/pp/13EA45.html",
      "3": 4.3,
      "4": "shoes",
      "5": 354,
      "6": "Super Shoes"
    }
});
curl -X POST \
  https://ariane.abtasty.com \
  -H 'content-type: application/json' \
  -d '{
  "cid": "60511af14f5e48764b83d36ddb8ece5a",
  "dl": "http%3A%2F%2Fabtastylab.com%2F60511af14f5e48764b83d36ddb8ece5a%2F",
  "ec": "RECOPRODUCT",
  "ea": "13EA45",
    el: "http://www.website.com/resources/13EA45.jpg",
    ev: 13.37,
    cd: {
      "1": 1586960579,
      "2": "http://www.website.com/pp/13EA45.html",
      "3": 4.3,
      "4": "shoes",
      "5": 354,
      "6": "Super Shoes"
    },
  "t": "EVENT",
  "vid": "18100217380532936", 
  "caid": "262762",
  "vaid": "873378"
}' --output ariane_response.tmp

AB Tasty’s product recommendation engine gets its data directly from your AB Tasty database, you will therefore use the common Universal Collect syntax to send data.

It is using the EVENT type of hit to register that a product page has been seend and that it needs to be acknowledge for further processing.

Common arguments

Specific arguments

Parameter Value Type Definition Default Value Mandatory
ec string “RECOPRODUCT” None Yes
ea string SKU None Yes
el string image URL None Yes
ev float price None Yes
cd object additionnal info None No

Custom dimension argument

The custom dimension argument (cd) sent with an object allows you to give the engine additional data about the product. This additional data will be sent back to you when getting the list of recommended products.

2. Getting the appropriate results

Example of GET request

https://product-recommendation-api-dot-prod-unicollect-211188.appspot.com/clients/7935db4b4858e45e6e3ab370db245d21/product_based?key=49445080

And its answer

{
    "MainProductSku": "49445080",
    "ProductRevenue": 52,
    "ProductImg": "https://www.website.com/pp/49445080_original_original_1.jpg",
    "ProductURL": "https://www.website.com/pp/49445080.html",
    "CD": "[{\"index\":6,\"value\":\"167\"},{\"index\":7,\"value\":\"Sample\"},{\"index\":8,\"value\":\"C080033118\"},{\"index\":1,\"value\":\"1586827892551\"},{\"index\":3,\"value\":\"29.71\"},{\"index\":4,\"value\":null},{\"index\":2,\"value\":\"https://www.website.com/sample/80045944.html\"},{\"index\":9,\"value\":\"Corps\"},{\"index\":5,\"value\":\"NOUVEAU\"}]",
    "RelatedProducts": [
        {
            "Sku": "49445081",
            "ProductRevenue": 13,
            "ProductImg": "https://www.website.com/pp/49445081_original_original_1.jpg",
            "ProductURL": "https://www.website.com/pp/49445081.html",
            "CD": "[{\"index\":6,\"value\":\"167\"},{\"index\":7,\"value\":\"Sample\"},{\"index\":8,\"value\":\"C080033118\"},{\"index\":1,\"value\":\"1586827892551\"},{\"index\":3,\"value\":\"29.71\"},{\"index\":4,\"value\":null},{\"index\":2,\"value\":\"https://www.website.com/sample/80045944.html\"},{\"index\":9,\"value\":\"Corps\"},{\"index\":5,\"value\":\"NOUVEAU\"}]"
        },
        {
            "Sku": "49445082",
            "ProductRevenue": 53,
            "ProductImg": "https://www.website.com/pp/49445082_original_original_1.jpg",
            "ProductURL": "https://www.website.com/pp/49445082.html",
            "CD": "[{\"index\":6,\"value\":\"167\"},{\"index\":7,\"value\":\"Sample\"},{\"index\":8,\"value\":\"C080033118\"},{\"index\":1,\"value\":\"1586827892551\"},{\"index\":3,\"value\":\"29.71\"},{\"index\":4,\"value\":null},{\"index\":2,\"value\":\"https://www.website.com/sample/80045944.html\"},{\"index\":9,\"value\":\"Corps\"},{\"index\":5,\"value\":\"NOUVEAU\"}]"
        },
        {
            "Sku": "49445083",
            "ProductRevenue": 23.99,
            "ProductImg": "https://www.website.com/pp/49445083_original_original_1.jpg",
            "ProductURL": "https://www.website.com/pp/49445083.html",
            "CD": "[{\"index\":6,\"value\":\"167\"},{\"index\":7,\"value\":\"Sample\"},{\"index\":8,\"value\":\"C080033118\"},{\"index\":1,\"value\":\"1586827892551\"},{\"index\":3,\"value\":\"29.71\"},{\"index\":4,\"value\":null},{\"index\":2,\"value\":\"https://www.website.com/sample/80045944.html\"},{\"index\":9,\"value\":\"Corps\"},{\"index\":5,\"value\":\"NOUVEAU\"}]"
        },
        {
            "Sku": "49445084",
            "ProductRevenue": 12.90,
            "ProductImg": "https://www.website.com/pp/49445084_original_original_1.jpg",
            "ProductURL": "https://www.website.com/pp/49445084.html",
            "CD": "[{\"index\":6,\"value\":\"167\"},{\"index\":7,\"value\":\"Sample\"},{\"index\":8,\"value\":\"C080033118\"},{\"index\":1,\"value\":\"1586827892551\"},{\"index\":3,\"value\":\"29.71\"},{\"index\":4,\"value\":null},{\"index\":2,\"value\":\"https://www.website.com/sample/80045944.html\"},{\"index\":9,\"value\":\"Corps\"},{\"index\":5,\"value\":\"NOUVEAU\"}]"
        },
        {
            "Sku": "49445085",
            "ProductRevenue": 104,
            "ProductImg": "https://www.website.com/pp/49445085_original_original_1.jpg",
            "ProductURL": "https://www.website.com/pp/49445085.html",
            "CD": "[{\"index\":6,\"value\":\"167\"},{\"index\":7,\"value\":\"Sample\"},{\"index\":8,\"value\":\"C080033118\"},{\"index\":1,\"value\":\"1586827892551\"},{\"index\":3,\"value\":\"29.71\"},{\"index\":4,\"value\":null},{\"index\":2,\"value\":\"https://www.website.com/sample/80045944.html\"},{\"index\":9,\"value\":\"Corps\"},{\"index\":5,\"value\":\"NOUVEAU\"}]"
        }
    ]
}

API call

On each page you want to display the recommended product you will have to call the following URL:

GET https://product-recommendation-api-dot-prod-unicollect-211188.appspot.com/clients/%CLIENT_ID%/product_based?key=%ITEM_SKU%

with

%CLIENT_ID% being your AB Tasty identifier and %PRODUCT_SKU% being the ID of the current item.

Parameter Value Type Definition Default Value Mandatory
key string Item SKU None Yes

Answer

The API will answer with a set of data corresponding to the current item along with a list of related products. Each item, including the current one, will be detailled with its SKU, the item price, the image URL, the URL and the set of custom dimension that has been last sent.

Displaying the product recommendation

You can now use the object contains in the API response to display a widget as needed on your website or application.