Documentation
Feedback
Guides
API Reference

Guides
Guides
Recommendations

Implementing product recommendations in Faststore

Learn how to implement product recommendations in FastStore stores.

This feature is in beta. If you're a VTEX client and want to use this feature in your business, contact VTEX Support.

The product recommendation feature in FastStore displays a curated selection of products based on custom recommendation strategies.

{"base64":"  ","img":{"width":1504,"height":496,"type":"gif","mime":"image/gif","wUnits":"px","hUnits":"px","length":3351718,"url":"https://vtexhelp.vtexassets.com/assets/docs/src/shelf-recommendation___403f15739cf14318a5b9ad8f16582d71.gif"}}

Before you begin

Make sure Intelligent Search is installed, enabled, and integrated with the catalog in your account. To do this, follow the instructions in these guides:

Receive approval for the product recommendations feature

Open a ticket with VTEX Support to request the use of the product recommendations feature for your FastStore account.

Instructions

Step 1 - Set up your account environment

After you receive the approval to use the product recommendations feature, the VTEX support team will prepare your account environment by:

  • Creating a Synerise workspace for recommendations.
  • Synchronizing your product catalog with the recommendation service.
  • Setting up API keys for secure access.
  • Generating a custom integration script for your store.

Step 2 - Implement the script in the FastStore project

To collect shopper product interaction events for training and delivering recommendations, implement the script provided by VTEX Support as a third-party script in your FastStore project. To do this, follow these instructions:

  1. Add a new section that fetches products and tracks views and click events, similar to a carousel.

    After creating this new section, you can add it to any part of the store, including Home, PDP, and PLP.

  2. Add the script provided by VTEX Support as a third-party script in your FastStore project. To add the script, follow the instructions in the Adding third-party scripts guide.

  3. Save the _snrs_uuid in the user's orderForm, so that when the order is placed, it is possible to attribute that sale to the user identified during navigation. When the ID is generated, it is necessary to save the user's ID in the orderForm during navigation using PUT to set multiple custom field values as shown below:


    _10
    fetch(`/api/checkout/pub/orderForm/$\{orderForm.id\}/customData/synerise`, {
    _10
    method: 'PUT',
    _10
    body: JSON.stringify({
    _10
    uuid: snrsUuidCookie,
    _10
    source: isMobile() ? 'WEB_MOBILE' : 'WEB_DESKTOP',
    _10
    }),
    _10
    })

  4. Validate that the _snrs_uuid was saved in the orderForm by retrieving the orderForm using GET Get current cart. The customData field returned should contain the added information.

  5. Send the POST Product View event following the API reference.

Step 3 - Train the models

Once the tracking script collects enough browser data, the VTEX team will train and configure the recommendation models for each strategy. The available strategies are:

NameDescription
Most popularProducts with the highest number of views
Recommended for youCustom recommendations based on user profile and behavior
Similar productsProducts similar to a specific one
Cross-sellComplementary products for a specific one that are commonly purchased together.
Best sellersThe store's best-selling products
Last seenProducts recently viewed by the user
Recent interactionsProducts most likely to engage the user in the future
Visually similar productsProducts visually similar to a specific one
Manual collectionRecommendations from a collection created manually

After the models are trained, they will be available for API-based recommendation displays in your store.

Step 4 - Integrate product recommendations

Once models for each selected strategy are trained, you can integrate product recommendations into your store and display them during shopper interactions by following these steps:

  1. Managing user session
  2. Fetching products for the recommendation component
  3. Tracking event interactions.

Managing user session

Use the POST Start Session endpoint to create a unique user ID for recommendations. This endpoint:

  • Generates a unique user ID (recommendationsUserId) for the session.
  • Links it to the provided order form ID.
  • Stores the ID in the vtex-rec-user-id cookie for session continuity.
  • Initializes recommendation tracking and personalization.

Call this endpoint on the first page view of each visit, before displaying any recommendations, and only if the _snrs_uuid is not already present. If orderFormId is not provided in the request body, the API attempts to retrieve it from the checkout.vtex.com cookie.

Request example:


_10
curl --request post \
_10
--url https://api.vtexcommercestable.com.br/api/recommend-bff/v2/users/start-session \
_10
--header 'Accept: application/json' \
_10
--header 'Content-Type: application/json' \
_10
--header 'host: apiexamples.vtexcommercestable.com.br' \
_10
--header 'x-forwarded-host: www.apixamples.com' \
_10
--header 'x-vtex-rec-origin: apiexamples/storefront/vtex.recommendation-shelf@2.x' \
_10
--data '{"orderFormId":"d761924de4254f6883a8ec2e9a28597d"}'

Response example:


_10
{
_10
"recommendationsUserId": "198e0f50-acf8-42f7-998a-5cd125464749"
_10
}

Persist the returned recommendationsUserId as _snrs_uuid and include it in all subsequent requests.

Fetching products for the recommendation component

Use the GET Fetch recommendations endpoint to fetch products for each shelf whenever a page contains a recommendation component (homepage, PDP, cart, PLP, etc.).

The campaign determines the type of recommendations returned, such as personalized recommendations, similar items, cross-sell, and others.

This endpoint retrieves a list of recommended products based on:

  • Campaign VRN (Virtual Resource Name) identifying the recommendation strategy. The VRN follows the pattern vrn:recommendations:{store-name}:{campaignType}:{campaignId}. Contact VTEX Support to obtain the campaignId.

    Available campaign types:

    • rec-top-items-v2: Best sellers
    • rec-persona-v2: Personalized recommendations
    • rec-similar-v2: Similar items
    • rec-cross-v2: Cross-sell
    • rec-cart-v2: Cart-based recommendations
    • rec-last-v2: Last seen
    • rec-interactions-v2: Recent interactions
    • rec-visual-v2: Visual similarity
    • rec-search-v2: Search-based recommendations
    • rec-next-v2: Next interaction
  • User context (from recommendationsUserId).

  • Page context (product ID, cart items, etc.).

Request example:


_10
curl --request get \
_10
--url 'https://api.vtexcommercestable.com.br/api/recommend-bff/v2/recommendations?an=apiexamples&campaignVrn=vrn%3Arecommendations%3Aapiexamples%3Arec-top-items-v2%3A123e4567-e89b-12d3-a456-426614174000&userId=198e0f50-acf8-42f7-998a-5cd125464749&products=product-id-1%2Cproduct-id-2%2Cproduct-id-3&salesChannel=1&locale=en-US' \
_10
--header 'Accept: application/json' \
_10
--header 'x-vtex-rec-origin: apiexamples/storefront/vtex.recommendation-shelf@2.x'

Response example:


_13
{
_13
"products": [
_13
"1234",
_13
"5678",
_13
"91011"
_13
],
_13
"correlationId": "rec-123e4567-e89b-12d3-a456-426614174000",
_13
"campaign": {
_13
"id": "123e4567-e89b-12d3-a456-426614174000",
_13
"title": "Most Popular Items",
_13
"type": "TOP_ITEMS"
_13
}
_13
}

Render the returned items as product cards on the shelf. After rendering, proceed to event tracking.

Tracking event interactions

To improve recommendation accuracy and measure effectiveness, you need to track how users interact with the recommended products. There are three types of events to track:

For accurate tracking, ensure that:

  • All events include the same recommendationsUserId.
  • Events are properly debounced to prevent duplicates.
  • View events are triggered only when shelves enter the viewport.

Recommendation views

Use the POST Recommendation view endpoint when a recommendation shelf becomes visible. This endpoint:

  • Records when recommendations are shown to users.
  • Provides data for click-through rate (CTR) analysis.
  • Helps train and improve recommendation models.
  • Should be called when shelves enter the viewport.

Request example:


_10
curl --request post \
_10
--url 'https://api.vtexcommercestable.com.br/api/recommend-bff/v2/events/recommendation-view?an=apiexamples' \
_10
--header 'Content-Type: application/json' \
_10
--data '{"userId":"user-id","correlationId":"correlation-id--from-recommendation-request","products":["product-id-1","product-id-2","product-id-3"]}'

Recommendation clicks

Use the POST Recommendation click endpoint when users interact with recommended products. This endpoint tracks user engagement with recommendations and should be called for each click on a product card.

Request example:


_10
curl --request post \
_10
--url 'https://api.vtexcommercestable.com.br/api/recommend-bff/v2/events/recommendation-click?an=apiexamples' \
_10
--header 'Content-Type: application/json' \
_10
--data '{"userId":"user-id","correlationId":"correlation-id--from-recommendation-request","product":"product-id"}'

Product views

Use the POST Product View endpoint when users view product details. This endpoint tracks all product detail page views.

VTEX automatically tracks product views once the Recommendations feature is set up in your store’s website, as instructed in Step 2. This event is only required for app implementations or other channels. Track product views for all sources to ensure comprehensive data collection for the recommendation models.

Request example:


_10
curl --request post \
_10
--url 'https://api.vtexcommercestable.com.br/api/recommend-bff/v2/events/product-view?an=apiexamples' \
_10
--header 'Content-Type: application/json' \
_10
--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
_10
--header 'x-vtex-rec-origin: apiexamples/storefront/vtex.recommendation-shelf@2.x' \
_10
--data '{"userId":"user-id","product":"product-id-1","source":"WEB_DESKTOP"}'

Contributors
2
Photo of the contributor
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
2
Photo of the contributor
Photo of the contributor
Was this helpful?
Suggest edits (GitHub)
On this page