Learn how to label and boost previously purchased items in search results.
Enhancing search results with labels for previously purchased items creates a more personalized and relevant user experience. This guide demonstrates how to implement a “Purchased” badge and prioritize these items in search results, helping users quickly identify products they’ve already bought.Implementing this aspect of the Advanced Personalization feature offers several advantages:
Lets users identify items for potential repurchase or review
Prevents accidental repurchases by reminding users of previous purchases
Guides users to related or updated versions of products they’ve bought before
Potentially increases customer loyalty and repeat purchases
This feature isn’t available on every plan.
Refer to your pricing plan to see if it’s included.
This structure lets you look up purchase dates by objectID,
the unique identifier used in your Algolia for each product.Pass this data to the search component:
React
function App() { return <SearchPage purchaseHistory={purchaseHistory} />;}
To display a badge for purchased items,
modify the search results by adding a custom attribute to each hit.
This information allows to label items in your search results.Create a SearchPage component that handles the InstantSearch setup:
To prioritize purchased items in the search results,
you can implement a custom sorting function.
This step can enhance the user experience by bringing previously purchased items to the top of the results.Implement a custom sorting function: