Fetch Recently Viewed Products [Beta]
Fetch Products that have been recently viewed by a Shopper
Contact support for using Beta Shopper APIs.
swat.shopper.fetchRecentlyViewedProducts
This API retrieves the products that are recently viewed by a shopper. For logged-in shoppers, all recently viewed are retrieved, while for non-logged-in shoppers, all recently viewed actions associated with their session on the device are retrieved. By default, the API returns a maximum of 12 recently viewed products.
Definition
swat.shopper.fetchRecentlyViewedProducts(onSuccess, onError)
Example
Here's an example of how you can use this API to fetch the Recently Viewed products:
// Define success callback
let onSuccess = function(data) {
// Successfully fetched the recently viewed products
console.log("These are the products recently viewed products by the shopper : ", data.recentlyViewed);
}
// Define error callback
let onError = function(error) {
// Error is an xhrObject
console.log("Error while fetching the shopper activity ", error);
}
// Call `shopper.fetchRecentlyViewedProducts` function
swat.shopper.fetchRecentlyViewedProducts(onSuccess, onError);
API Parameters
Argument | Type | Description |
---|---|---|
onSuccess | function | Called when the Recently Viewed Products are fetched successfully. |
onError | function | Called when there is an error while fetching Recently Viewed Products |
Success Response
The success response contains by default, a maximum of 12 Recently Viewed products in the recentlyViewed
key.
{
"recentlyViewed": [
{
// Number of times the product is viewed
"count": 28,
// Product ID from the Platform
"productId": 7096231231686,
// Timestamp at which the product was viewed last time
"lastViewedTime": 1709013095458,
// Varaint ID form the Platform
"variantId": 41254655393990,
// Produc URL
"productURL": "https://demo.swym.it/products/ceramic-oval-basin",
// Timestamp of the latest order placed with the product after it was viewed
"lastOrderTimestamp": 1708426159001,
// ID of the variant that was ordered after the product was viewed
"lastOrderedVariantId": 41254655393990,
// ID of the latest order placed with the product after it was viewed
"lastOrderId": 2849832
}
]
}
Other References
Recently Viewed Fields
Argument | Type | Description |
---|---|---|
count | number | Number of times the product is viewed |
productId | number | Product ID from the Platform |
lastViewedTime | number | Last viewed Timestamp in UTC |
productURL | string | Product URL |
variantId | number | Variant ID from the Platform |
lastOrderTimestamp | number | Timestamp of the latest order placed with the product after it was viewed |
lastOrderId | number | ID of the latest order placed with the product after it was viewed |
lastOrderedVariantId | number | ID of the variant that was ordered after the product was viewed |
Updated 9 months ago