The JS API can be used to register callbacks to hook into the recommendation events. To register a listener for a callback, use api.listen(callbackId, callbackFunction) function.
Post Render Callback
Called when Nosto has responded and finished recommendation placement.
nostojs(function(api){
api.listen('postrender',function(event){
console.log(event.filledElements);
console.log(event.unFilledElements);
});
});
Fields
Field
Type
Reason
filledElements
Array
Contains a list of recommendation slots that contain recommendations
unFilledElements
Array
Contains a list of recommendations slots that did not have get recommendations.
​
Pre Render Callback
‌
Called when Nosto has responded but not yet rendered content. The event contains information about the visitor's preferences.
nostojs(function(api) {
api.listen('prerender', function(event) {
console.log(event);
});
});
‌
Fields
Field
Type
Reason
affinityScores
Object
Describes visitor's most preferred brands and categories, the object has two attributes top_brands and top_categories which are arrays that contain maximum 5 most preferred brands/categories for the visitor. Example content:
{
top_brands:[
{name:"Acme", score:0.8},
{name:"Universal", score:0.3}
]
}
segments
Object
Information about which segments the visitor falls into. active_segments field contains a list of segment identifiers that were active on the latest request to Nosto. Segment identifiers can be retrieved from the Nosto backend, or queried from the GraphQL API.
Example content: