Product Detail Pages
Product Detail Pages (PDPs) are critical decision points in the e-commerce journey. A user has shown interest in a specific item, but it might not be exactly right – perhaps the color is off, the price is slightly too high, or they simply want to see comparable options before committing. Leaving them at a dead end if the featured product isn't perfect risks losing the sale entirely. This is where "Similar Items" or "More Like This" recommendations become invaluable.
By showcasing relevant alternatives directly on the PDP, businesses can keep users engaged, facilitate product discovery, increase the likelihood of finding the right product, and ultimately boost conversion rates and average order value. Unlike cross-sells or upsells like "Frequently Bought Together", similar item recommendations focus on providing comparable choices to the item currently being viewed. Building the intelligence to accurately identify true similarity, however, involves tackling significant technical hurdles.
The Shaped Approach: Simplified Similarity with similar_items
Building robust similar item recommendations involves navigating a maze of data processing, complex ML modeling, and infrastructure management. Shaped dramatically simplifies this with its dedicated similar_items
endpoint, powered by sophisticated models that automatically learn complex similarity patterns.
Shaped's underlying models (often leveraging Transformers) learn deep representations of items based on both their metadata (content) and how users interact with them (collaborative signals). The similar_items
endpoint provides direct, low-latency access to this learned understanding.
How Shaped Streamlines Similar Item Recommendations:
- Unified Data Integration: Connect your item metadata and user interaction data using Shaped's connectors. The same data used for personalization feeds the similarity understanding.
- Automated Model Training: Shaped handles the complex process of training models that intrinsically understand nuanced item similarities, blending content and collaborative signals automatically.
- Dedicated
similar_items
API: A single, simple API call retrieves a list of items deemed most similar to a givenitem_id
, based on the model's deep understanding. - Contextual Similarity (Optional): You can optionally provide a
user_id
to thesimilar_items
call. This allows Shaped to potentially tailor the similarity context slightly based on that specific user's preferences and history, although the primary driver remains item-to-item similarity. - Managed Infrastructure: Shaped manages the complex model training, serving infrastructure, and low-latency API delivery needed for real-time recommendations.
Building a "Similar Items" Carousel with Shaped
Let's illustrate using Shaped's similar_items
endpoint to populate a "More Like This" section on a PDP.
Goal: When a user views the PDP for ITEM_101
, display a list of the 5 most similar items.
1. Ensure Data is Connected: Assume item_metadata
(with fields like title
, description
, image_url
, category
, brand
) and user_interactions
datasets are connected and used for model training in Shaped.
2. Define Your Shaped Model (YAML): A standard recommendation model definition is usually sufficient. The model trained for personalized ranking (rank
) often inherently learns the relationships needed for similar_items
. Ensure item metadata fields are included.
model:
name: product_discovery_engine # Can power rank, similar_items etc.
connectors:
- type: Dataset
name: item_metadata
id: items
- type: Dataset
name: user_interactions
id: interactions
fetch:
items: |
SELECT
item_id,
title,
description, # Important for content understanding
category,
brand,
image_url,
product_url
FROM items
events: |
SELECT
user_id,
item_id,
timestamp AS created_at,
event_value,
1 AS label # label is the objective of the model, in this case 1 represents a conversion event
FROM interactions
3. Create the Model:
shaped create-model --file product_similarity_model.yaml
4. Monitor Training: Wait for the model product_discovery_engine
to become ACTIVE
.
shaped view-model --model-name product_discovery_engine
5. Fetch Similar Items (Application Backend Logic): When a user lands on the PDP for ITEM_101
:
- Step A (Your Backend): Identify the
item_id
of the product being viewed ('ITEM_101'
). Optionally, identify theuser_id
if the user is logged in and you want potentially contextualized similarity. - Step B (Your Backend): Call Shaped's
similar_items
API endpoint.
- Python
- JavaScript
const { Shaped } = require('@shaped/shaped');
const shapedClient = new Shaped(); // Assumes API key configured
const modelName = 'product_discovery_engine';
const currentItemId = 'ITEM_101';
const loggedInUserId = 'USER_456'; // Optional: null for anonymous
const numSimilarItems = 5;
const response = await shapedClient.similarItems({ // Note: camelCase method name
modelName: modelName,
itemId: itemId,
userId: userId, // Pass null or undefined if anonymous
limit: numSimilarItems,
returnMetadata: true
});
console.log(`Found ${similarItemsList.length} similar items for ${itemId}`);
from shaped import Shaped
shaped_client = Shaped()
model_name = 'product_discovery_engine'
current_item_id = 'ITEM_101'
logged_in_user_id = 'USER_456' # Optional: set to None if user is anonymous
num_similar_items = 5
response = shaped_client.similar_items(
model_name=model_name,
item_id=current_item_id,
# Optionally provide user_id for potentially contextualized similarity
user_id=logged_in_user_id if logged_in_user_id else None,
limit=num_similar_items,
return_metadata=True # Get full details for display
)
print(f"Found {len(similar_items_list)} similar items for {current_item_id}")
Example API Response (with return_metadata=False
):
{
"ids":[
"ITEM_427",
"ITEM_182",
"ITEM_332",
"ITEM_827",
"ITEM_403"
]
}
(With return_metadata=True
, each ID would be replaced/accompanied by its full metadata object)
- Step C (Your Frontend): Use the list of similar items returned in the
response.metadata
to render the "Similar Items" carousel on the PDP.
Conclusion: Effortless Similarity, Deeper Engagement
Showing relevant similar items on PDPs is a powerful way to keep users engaged and guide them towards the perfect product. However, building the underlying intelligence traditionally requires complex data pipelines, sophisticated content-based or collaborative filtering models, and significant infrastructure management.
Shaped cuts through this complexity with its similar_items
endpoint. By leveraging automatically trained models that understand nuanced item relationships from both content and user behavior, Shaped allows you to easily integrate powerful similar item recommendations with a simple API call. Reduce development time, eliminate infrastructure headaches, and start providing more engaging product discovery experiences today.
Ready to add powerful "Similar Items" recommendations to your PDPs?
Request a demo of Shaped today to see the similar_items
endpoint in action. Or, start exploring immediately with our free trial sandbox.