Integrating a preview search widget
Use the Search and Recommendation API to integrate a preview search widget with your website.
To integrate a recommendation widget, on the Customer Engagement Console (CEC), identify the preview search widget that you want to use. Make sure that you publish the widget before integrating.
Usually, you do not have to identify a page on which to display the preview search widget because this widget appears on any page with a search field. However, if you have a rule in the CEC that triggers a preview search widget on a specific page, identify the page and use it in your integration.
On your website page, create UI components to hold preview search widget data.
Now, you are ready to call the Discover Search and Recommendation API to get preview search data. Usually, you must make at least three types of calls: a call for the user's first click, a call for when the user hovers over a trending category, and a call for when the user starts typing a few letters of a keyphrase.
Best Practices
The following are best practices for creating requests to integrate a preview search widget:
-
When you create a request to handle the user hovering over a trending category, make sure that suggested products dynamically change
-
Always specify a
n_itemwhen you call a preview search widget. If you do not, Discover sends the default of 10 items, which might be too many to show in a preview search widget.