Prompt
How do I use behavioral signals in an ecommerce recommendation engine?
Latest observation
Behavioral signals are one of the most useful inputs for an ecommerce recommendation engine because they reveal what users actually do, not just what they say they like.
1) What counts as behavioral signals
Common signals include:
- Views / clicks: items a user looked at
- Add-to-cart: stronger intent than a view
- Purchases: strongest positive signal
- Search queries: explicit intent
- Dwell time / scroll depth: engagement strength
- Wishlist / favorites: long-term interest
- Returns / removals / skips: negative or weak signals
- Purchase frequency, recency, basket size: user purchase patterns
2) Turn behaviors into features
You usually convert raw events into recommendation features such as:
- Recency: how recently an item was viewed or purchased
- Frequency: how often the user interacts with a category/brand/item
- Intensity: add-to-cart > click > view
- Session context: what the user is doing right now
- Category affinity: repeated interest in running shoes, skincare, etc.
- Brand affinity: preference for a particular brand
- Price sensitivity: typical spend range
- Temporal patterns: weekday vs weekend, seasonal interest
A common approach is to assign weighted scores, for example:
- view = 1
- click = 2
- add-to-cart = 4
- purchase = 8
Then aggregate by user-item, user-category, or user-brand.
3) Use signals for different recommendation tasks
Behavioral signals can power several recommendation types:
Personalized ranking
Rank products based on predicted likelihood of engagement or purchase.
“Because you viewed X”
Recommend similar or complementary items based on recent browsing.
“Frequently bought together”
Use co-purchase and basket patterns to recommend bundles or accessories.
Session-based recommendations
Use current-session behavior to adapt quickly, even for anonymous users.
Next-best-action
Recommend the next most useful item in the funnel:
- view → similar products
- cart → accessories or checkout prompts
- post-purchase → replenishment or cross-sell
4) Model choices
You can use behavioral data in several ways:
Simple rule-based systems
- Similar products based on co-view or co-purchase counts
- Popular items by category and recent trend
- Works well as a baseline
Collaborative filtering
- Users with similar behavior get similar recommendations
- Item-item collaborative filtering is very common in ecommerce
Content + behavioral hybrid
- Combine item attributes with user behavior
- Useful for cold start and better explanations
Sequence models / session models
- Use order of actions to predict next item
- Good for short-term intent
Learning-to-rank / deep recommendation models
- Train on historical interactions to predict conversion or relevance
- Can combine many signals at once
5) Weight signals by strength and recency
Not all signals should count equally.
A practical pattern:
- Stronger actions get higher weight
- More recent actions get higher weight
- Negative actions reduce score
Example:
- A product viewed 10 times last week may be more relevant than one purchased a year ago
- A recent cart addition may outrank an old wishlist item
You can use time decay, such as:
- score × exp(-days_since_event / decay_factor)
6) Handle negative and noisy signals
Behavioral data is messy.
Watch for:
- accidental clicks
- bot traffic
- repeat views caused by poor UX
- purchases that don’t imply preference, like gifts or one-time needs
Mitigations:
- session filters and bot detection
- thresholding very short dwell times
- separating “intent” from “purchase context”
- using returns/refunds as negative feedback
7) Deal with cold start
For new users:
- use popular items, trending items, geo/time-based trends
- infer from first few clicks/searches
- ask for preferences directly
For new products:
- use content metadata:
- category
- brand
- price
- description
- embeddings from text/images
- boost exposure to gather early feedback
8) Evaluate properly
Offline metrics:
- precision@k
- recall@k
- MAP
- NDCG
- AUC
Business metrics:
- CTR
- add-to-cart rate
- conversion rate
- revenue per session
- average order value
- repeat purchase rate
Use A/B tests to confirm real impact, because offline gains don’t always translate to business gains.
9) Practical architecture
A common pipeline:
- Collect event logs
- Clean and normalize events
- Build user/item feature stores
- Generate candidates
- Rank candidates with a model
- Serve recommendations in real time
- Log impressions and outcomes for retraining
10) Good starting strategy
If you’re just starting, do this:
- Use item-item collaborative filtering from views, carts, and purchases
- Add recency weighting
- Add business rules for out-of-stock, margins, and diversity
- Evaluate with A/B tests
- Expand to hybrid or sequence models later
If you want, I can also give you:
- a sample feature schema
- a Python example
- or a production architecture for an ecommerce recommender.