Techdocs
Search…
Recommendation Callbacks
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.
1
nostojs(function(api) {
2
api.listen('postrender', function(event) {
3
console.log(event.filledElements);
4
console.log(event.unFilledElements);
5
});
6
});
Copied!

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.
1
nostojs(function(api) {
2
api.listen('prerender', function(event) {
3
console.log(event);
4
});
5
});
Copied!

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:
{
active_segments:[
{id:"5a497a000000000000000004"},
{id:"5aa12b8960b2352d326d77f1"}
]
}
Last modified 11mo ago