Personalized recommendations
Personalized recommendations adapt to each shopper. Two shoppers who open the same home page or product page see different products, based on what each of them clicked, added to cart and bought.
LupaSearch personalizes recommendations in two ways. They work best together:
| What | Shows | How to set up |
|---|---|---|
| Recent activity source | The exact products this shopper recently clicked, added to cart or bought | Add the recentActivity source to the recommender |
| Custom query rule with personalization | New products similar to what this shopper likes: same brands, categories and other attributes | Add a custom query rule with personalization enabled |
The second one also works where there is no product to recommend for, such as the home page, the cart or an empty search page (_all requests).
How it works
- The shopper interacts with products. Each item click, add to cart and purchase is sent to LupaSearch with the shopper's
userId(orsessionId). Clicks on recommended products count too. - LupaSearch builds a profile. For every product the shopper interacts with, LupaSearch counts its attribute values, for example
brand: Canonorcategory: Cameras. Each event type adds its own weight, so a purchase can count more than a click. The profile is kept for 8 hours after the shopper's last interaction. Every new event extends it by another 8 hours. - Recommendations use the profile. When the shopper requests recommendations with the same
userId, products with the shopper's top values for each attribute get a higher score. A shopper who clicked several Canon cameras sees Canon products and cameras ranked first, including ones they haven't seen yet.
Shoppers without a profile (new visitors, or requests without a userId) get the same recommendations as everyone else, so the setup is safe to enable for all traffic.
Requirements
- Send events. Item clicks, add to cart and purchase events must be tracked. The LupaSearch client does this for you. With your own integration, use the
/eventsendpoint. - Use the same identifier everywhere. Send the same
userIdwith events and with recommendation requests. Use your customer id for logged-in shoppers. UsesessionIdfor anonymous visitors.
POST /v1/events
{ "queryKey": "xxxxxxxxxxxx", "name": "itemClick", "itemId": "24", "userId": "customer-1093", "sessionId": "s-8f2c" }
GET /v1/recommendations/document/_all?recommendationQueryKey=r-xxxxxxxxxxxx&userId=customer-1093&sessionId=s-8f2c
Setup: "Recommended for you"
This setup gives a "Recommended for you" widget that works on any page, including _all requests.
1. The recommender
{
"documentQueryKey": "xxxxxxxxxxxx",
"limit": 10,
"sources": [
{ "type": "recentActivity", "limit": 5, "weight": 50 },
{
"type": "trendingItems",
"weight": 15,
"maxAgeDays": 7,
"itemClickBoost": 1,
"addToCartBoost": 2,
"purchasesBoost": 5
}
]
}
recentActivitybrings back products the shopper recently interacted with.trendingItemsfills the remaining places with popular products, and covers new visitors.
2. The personalization rule
Add a custom query rule with the always condition:
{
"name": "Personalized picks",
"enabled": true,
"configuration": {
"conditions": [{ "type": "always" }],
"conditionMatch": "all",
"behavior": "merge",
"action": {
"type": "searchQuery",
"query": {
"searchText": "",
"personalization": {
"enabled": true,
"eventWeight": { "itemClick": 10, "addToCart": 40, "purchasedItems": 70 }
},
"sort": [{ "_relevance": "desc" }, { "_clickCount": "desc" }],
"limit": 5
}
}
}
}
How the parts fit together:
- Empty
searchTextmatches the whole catalog. Personalization then ranks it by the shopper's profile. sortmust start with_relevance. Personalization works by raising the relevance score. If you sort by_clickCountalone, every shopper gets the same most-clicked products. With_relevancefirst,_clickCountonly breaks ties, so new visitors still get popular products.limitmust stay below the recommender'slimit. Rule results come first. If they fill the whole limit, the recent activity and trending sources don't run. With 5 out of 10, the shopper gets 5 personalized picks followed by recently viewed and trending products.
Event weights
eventWeight sets how much each type of event counts in the profile, from 1 to 100.
| Event | Suggested weight | Why |
|---|---|---|
itemClick | 10 | Interest, but often just browsing |
addToCart | 40 | Strong intent |
purchasedItems | 70 | The strongest signal of what the shopper likes |
With equal weights, a purchase counts the same as a single click.
Results you can expect
Example: one store, one _all recommender with the setup above.
| Shopper | Personalized picks |
|---|---|
| Clicked 3 photo cameras and 2 video cameras | Canon, Sony and Nikon cameras, plus Panasonic and Kodak cameras they haven't seen |
| Clicked and added perfumes to cart | Their perfumes, plus other perfumes of the same type |
| New visitor, no activity | The store's most clicked products |
Combining personalization with business rules
The personalization rule is a regular custom query, so you can add filters and boosts. Personalization then works within your rules.
Only new-season products, ranked for the shopper
For example, only products from the new collection, preferring well-rated ones, then the shopper's taste:
{
"type": "searchQuery",
"query": {
"searchText": "",
"filters": { "collection": ["Winter 2026"], "stock_status": ["IN_STOCK"] },
"boost": { "rating": 2 },
"personalization": { "enabled": true, "eventWeight": { "itemClick": 10, "addToCart": 40, "purchasedItems": 70 } },
"sort": [{ "_relevance": "desc" }],
"limit": 5
}
}
The custom query's filters only apply to the custom query. If the recommender sources must follow the same restriction, add a separate filter rule with the same filters. Otherwise recent activity and trending products from other collections will fill the remaining places.
Category pages: "Recommended for you in Laptops"
Public filters from the request apply to the personalization rule and to the sources. Use the same recommender on a category page and pass the category:
GET /v1/recommendations/document/_all?recommendationQueryKey=r-xxxxxxxxxxxx&userId=customer-1093&filters[category][]=Laptops
All recommended products are laptops, ranked by the shopper's preferences, for example their favorite brand first. Multiple values, other attributes and price ranges work the same way. If the filter is narrow and the rule finds fewer products than its limit, the sources fill the rest, within the same filter.
Product pages
On a product page, the personalization rule shows products the shopper likes, not products related to the viewed one. For a product page, combine both:
- A recommender with the similar items (
moreLikeThis) source, so results relate to the viewed product. - The
personalizationoption of the similar items source, which ranks similar products by the shopper's profile.
If you add the personalization rule to a product page recommender, exclude the viewed product with "exclusionFilters": { "id": ["[id]"] }. Custom queries don't exclude it automatically.
Things to know
- A changing interest takes time to show. The profile adds up all activity while it is kept, so earlier interests keep their weight. A shopper who browsed laptops for an hour and then switched to phones still sees mostly laptops until phones catch up.
- Returning shoppers start fresh. After 8 hours without activity the profile expires. A shopper who comes back the next day gets non-personalized recommendations until they interact with products again. LupaSearch admins can adjust this period on request.
- Already-seen products can take personalized places. The personalization rule can return products the shopper already interacted with, which the recent activity source returns too. Duplicates are removed, but fewer places are left for new products.
- Purchased products may be recommended again. The recent activity source returns products regardless of whether they were bought. For products people don't buy twice, consider a lower
recentActivityweight.
Testing
The recommender test panel in the LupaSearch console lets you try personalization without touching your site:
- Open the recommender test and enter a user id.
- Click products in the results to simulate that shopper's clicks. The results update right away with the new activity.
- Compare with an empty user id or an id with no activity. The personalized picks should differ, while the new visitor gets popular products.
- Repeat with public filters, if the recommender is used on category pages.
You can also enter the user id of a real shopper who has recent activity on your site, or send itemClick and addToCart events for a test user with the /events endpoint. New events affect recommendations right away.