Recommendations
Property | Type | Default |
---|---|---|
idField |
number | 'productId' |
location |
object | Read More |
iNav |
object | Read More |
productSuggestions |
object | Read More |
overrides |
object | Read More |
idField
The field used to track products for integration with recommendations services.
location
By default, the location service is disabled. Enable location service and use resolved location to request recommended suggestions. Set properties as undefined or as false to disable.
Property | Type |
---|---|
distance |
string |
minSize |
number |
An example location config:
location: {
distance: '100km',
minSize: 10,
}
distance
The max distance from the customer in kilometers or miles. The distance is specified as a string in the format *n*km
or *n*mi
where n is a non-negative integer.
minSize
The minimum required products returned in the response from a request with the location service enabled.
If there are not enough products in the initial response with the location service on, then another request will be sent with the location service off and the result will be used regardless of the number of products returned.
iNav
Option for sorting navigations and the refinements within those navigations based on popularity
Property | Type | Default |
---|---|---|
navigations |
object | |
refinements |
object | |
minSize |
number | |
size |
number | 10 |
window |
day , week or month |
day |
An example iNav config:
iNav: {
navigations: {
sort: true,
pinned: ['category2', 'category3']
},
refinements: {
sort: ['category1'],
pinned: {
category2: ['refinement-a', 'refinement-b'],
category1: ['refinement-c', 'refinement-d']
}
},
size: 10,
minSize: 5,
window: 'day'
}
size
The number of navigations to fetch from the API
minSize
The minimum required navigations returned in the response from an iNav request for a specific query.
If minSize is not set then it defaults to size.
If there are not enough navigations in the response, then an iNav request will be sent without a query and the returned navigations will be whatever navigations are returned in the response, even if they are less than the minSize amount.
window
How far to look back to determine popularity
navigations
Option for sorting navigations
Property | Type | Default |
---|---|---|
sort |
boolean | false |
pinned |
array |
sort
Whether or not to sort the navigations based on their popularity
pinned
An array holding the names of navigations to optionally keep pinned at the top of the navigations, regardless of popularity.
Using the above config as a reference:
category2
and category3
would be pinned up above all other navigations (in the order specified in the given array) no matter their popularity
refinements
Option for sorting refinements within the navigations
Property | Type | Default |
---|---|---|
sort |
boolean or string[] | false |
pinned |
{ [key: string]: string[] } |
sort
Whether or not to sort the refinements based on their popularity. When it is a boolean, all refinements will be sorted or unsorted.
When it is an array of strings, it will only sort the refinements within the given navigations.
pinned
An object whose keys match the names of the navigations, with each key corresponding an array of strings matching refinement names in order to be pinned to the top of their respective navigation menus
Using the above config as a reference:
-
In the navigation
category2
, the refinementsrefinement-a
andrefinement-b
would be pinned up above all other refinements (in the order specified in the given array) -
In the navigation
category1
, the refinementsrefinement-c
andrefinement-d
would be pinned up above all other refinements (in the order specified in the given array)
Note that the navigations specified to be pinned in navigations
do not have to be the same navigations with their refinements pinned in refinements
, in the above config, navigations category2
and category3
are being pinned, but we are pinning refinements within category1
and category2
productSuggestions
Property | Type | Default |
---|---|---|
productCount |
number | 4 |
mode |
string | 'popular' |
productCount
The number of recommended products to request.
mode
The type of recommended products to request. Options are 'popular'
, 'trending'
and 'recent'
.
overrides
Recommendations makes 4 API calls that may be overrided:
navigations
calls the recommendations API and powers the recommended navigations.ids
calls the recommendations API and powers the recommended product ids.products
calls the search API and powers the recommended products.autocompleteSuggestions
calls the recommendations API and powers the recommended suggested keywords.
These overrides let us add additional configuration to these calls.
Property | Type |
---|---|
navigations |
object |
ids |
object |
products |
object |
autocompleteSuggestions |
object |
navigations
The overrides to use for your recommended navigations to the recommendations API. Please refer to Recommendations API for what parameters you can pass in here.
For example, we can override the window used:
recommendations: {
overrides: {
navigations: {
window: 'month'
}
}
}
You can also use a function that returns an object to set the overrides:
recommendations: {
overrides: {
suggestions: (currReq, prevReq) => {
// do stuff
return { ...currReq, window: 'month' };
}
}
}
ids
The overrides to use for your recommended ids to the recommendations API. Please refer to Recommendations API for what parameters you can pass in here.
For example, we can override the target used:
recommendations: {
overrides: {
ids: {
target: 'productId'
}
}
}
You can also use a function that returns an object to set the overrides:
recommendations: {
overrides: {
ids: (currReq, prevReq) => {
// do stuff
return { ...currReq, target: 'productId' };
}
}
}
products
The overrides to use for your recommended products to the search API. Please refer to SEARCH API for what parameters you can pass in here.
For example, we can override the query used:
recommendations: {
overrides: {
products: {
query: 'dress'
}
}
}
You can also use a function that returns an object to set the overrides:
recommendations: {
overrides: {
products: (currReq, prevReq) => {
// do stuff
return { ...currReq, query: 'dress' };
}
}
}
autocompleteSuggestions
The overrides to use for your recommended keyword suggestions to the recommendations API. Please refer to Recommendations API for what parameters you can pass in here.
For example, we can override the size used:
recommendations: {
overrides: {
autocompleteSuggestions: {
size: 2
}
}
}
You can also use a function that returns an object to set the overrides:
recommendations: {
overrides: {
autocompleteSuggestions: (currReq, prevReq) => {
// do stuff
return { ...currReq, size: 2 };
}
}
}