Smart Collections
Usage
Use the following code for a given visited shopper collection. The callback function will contain the relevant products and filters matching the visited collection:
Example
window.FastSimonSDK.smartCollections({
categoryID:"555",
callback: (response) => {
// do stuff
// do more stuff
}
});
/* example with narrow & sort */
window.FastSimonSDK.smartCollections({
categoryID:"555",
narrowBy: [["Colour","colour:white"],["Colour","colour:green"],["Size","S"],["Price_from_to","36-95"]],
sortBy: window.FastSimonSortBy.AtoZ,
callback: (response) => {
// do stuff
// do more stuff
}
})
Options
Option | Type | Description |
---|---|---|
categoryID | string (required) | the category / collection you want results for |
callback | (Response) => void (required) | callback to handle the results |
page | number (default=1) | use for pagination |
productsPerPage | number (default=dashboard_config) | use for custom product count, note: this does not support pagination |
sortBy | sortBy (default=relevancy) | callback to handle the results |
narrowBy | Narrow [] | use for filtering |
facets | boolean (default=true) | use facets:false if you do not need filters |
withAttributes | boolean (default=false) | use withAttributes:true if you want to include attributes in the product response, Note: this might slow serving |
Response
Note: the callback might run twice to optimize speed, there are two scenarios:
- Products and facets were fetched together - callback runs once with be called only once with action "product and facets".
- Products were fetched but facets are still fetching - callback will run twice:
- action "products" will come first and call the callback for the first time
- action "product and facets" will call the callback again once facet fetch is completed
TypeScript Typing
interface Response {
action: "products" | "facets and products"
payload: {
ancestors: CategoryAncestor[]
categoryID: string
products: Product[]
facets?: Facet[]
totalResults: number
sortBy?: SortBy,
narrow?: Narrow[],
isNoResults?: boolean
page?: number
pageCount?: number
}
}
Reporting Implementation (must for analytics)
Please follow the guideline to report shopper behaviour on the recommendation widget in order to get accurate Analytics in the Fast Simon dashboard as well as greater personalized accuracy
- Collection Events - report whenever you call smartCollections...
- Products Viewed From Collection - report whenever product is clicked
- Quick View - if implement report "used" whenever quick view button is clicked