
When providing product recommendations on the page displaying the cart summary or during the checkout process, it’s essential to avoid suggesting items the customer has just added to their cart — otherwise, the experience can feel redundant and irrelevant.

In this use case, we build a recommendation that suggests from 1 to 10 products based on **last seen activity**, while using a **static filter to exclude the last 20 items added to the cart**.

This setup ensures that:
- The recommendation is grounded in the shopper’s actual behavior (last seen),
- Redundancy is avoided by excluding what was just added to cart,
- The experience feels intentional and clean, encouraging further discovery.


  <div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

  You can further enhance the experience by using item context (e.g. showing products in the same style, size, or color as those already viewed) — all directly supported through product feed attributes.

  </div></div></div>


## Prerequisites 
---
- Implement a [tracking code](/developers/web/installation-and-configuration) into your website.
- [Configure AI engine](/docs/settings/configuration/ai-engine-configuration/engine-configuration-for-recommendations). Enable last seen recommendation model.
- Implement the [transaction events](/developers/web/transactions-sdk) using [SDK](/developers/web/transactions-sdk) or [API](https://developers.synerise.com/DataManagement/DataManagement.html#operation/CreateATransaction).

## Process
---

In this use case, you will go through the following steps:
1. [Create an aggregate returning IDs of the 10 last seen products](#create-an-aggregate-returning-last-seen-products).
2. [Create an aggregate returning SKUs of the last 20 products added to cart](#create-an-aggregate-returning-last-20-products-added-to-cart).  
3. [Prepare an AI recommendation](#prepare-an-ai-recommendation) which excludes recently bought and items which are currently in the cart.

## Create an aggregate returning last seen products
---
In this part of the process, create an aggregate that returns the ID of the last 10 products a customer had visited. The recently viewed product itself will not display in the template, but will serve as a context for recommendations.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > Live Aggregates > Create aggregate**.
2. As the aggregate type, select **Profile**.  
2. Enter the name of the aggregate.
3. Click **Analyze profiles by** and select **Last Multi**. In **Size**, enter `10`. You can also add more results.
4. From the **Choose event** dropdown list, select the **Visited page** event.
5. As the event parameter, select **product:retailer_part_no**.
6. Click the **+ where** button.
7. From the **Choose parameter** dropdown list, select the **product:retailer_part_no** parameter.
8. From the **Choose operator** dropdown list, select **Is true (Boolean)**.
9. Using the date picker in the lower-right corner, set the time range to **Last 7 days**. Confirm your choice with the **Apply** button.
7. Click **Save**.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/email_aggregate_lsp.png" alt="The view of the aggregate configuration"  class="large">
<figcaption>Configuration of the aggregate returning the IDs of the last seen products</figcaption>
</figure> 

## Create an aggregate returning last 20 products added to cart
---
In this part of the process, create an aggregate returning SKUs of the last 20 products added to cart in the last 30 days.
1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > Live Aggregates > Create aggregate**.
2. As the aggregate type, select **Profile**.  
2. Enter the name of the aggregate.
3. Click **Analyze profiles by** and select **Last Multi**. In **Size**, enter `20`. You can also add more results.
4. From the **Choose event** dropdown list, select the **product.addToCart** event.
5. As the event parameter, select **$sku**.
9. Using the date picker in the lower-right corner, set the time range to **Last 30 days**. Confirm your choice with the **Apply** button.
7. Click **Save**.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/lastseen11.png" alt="The view of the aggregate configuration"  class="large">
<figcaption>Configuration of the aggregate returning the SKUs of the last 20 items added to cart</figcaption>
</figure> 


## Prepare an AI recommendation
---
In this part of the process, you will configure Last Seen AI Recommendations which excludes 10 recently visited items and last 20 products that have been added to cart. This will ensure that we do not recommend products that a customer has most recently interacted with.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/ai-hub-icon.svg" alt="AI Hub icon" class="icon" > **AI Hub > (AI Recommendations) Models > Add recommendation**.
2. Enter the name of the recommendation (it is only visible on the list of recommendations).
3. In the **Type & Items Feed** section, click **Define**.
4. From the **Items Feed** dropdown list, select an item feed.
5. In the **Type** section, choose the **Last seen** recommendation type.
6. Confirm the settings by clicking **Apply**.
7. In the **Items** section, click **Define**.
    2. Define the minimum and maximum number of items that will be recommended to the customer in each slot.
    3. Define [Static filters](/docs/ai-hub/recommendations-v2/creating-recommendation-campaign#static-filters) and [Elastic filters](/docs/ai-hub/recommendations-v2/creating-recommendation-campaign#elastic-filters).
    4. In our case, in the **Static filter** section, click **Define filter**.  
    5. Select **Visual Builder**.  
    6. Click **Select value**.
    5. Choose **itemId**.
    6. As an operator, choose **Not in**.
     7. Click the icon which appeared next to the field with operator and from the dropdown list, select **Aggregate**.
    8. From the list, choose the [aggregate, with 20 products added to the cart, created in the previous step](#create-an-aggregate-returning-last-20-products-added-to-cart).
    4. Confirm by clicking **Apply**. 
        <figure>
        <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/lastseen6.png" alt="The view of the aggregate configuration"  class="large">
        <figcaption>Configuration of the static filter</figcaption>
        </figure> 
4. In the **Elastic filter** section, click **Define filter**.  
    5. Select **Visual Builder**.  
    6. Click **Select value**.
    5. Choose **itemId**.
    6. As an operator, choose **In**.
     7. Click the icon which appeared next to the field with operator and from the dropdown list, select **Aggregate**.
    8. From the list, choose the [aggregate, with last seen products, created in the previous step](#create-an-aggregate-returning-last-seen-products).
    4. Confirm by clicking **Apply**. 
        <figure>
        <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/lastseen5.png" alt="The view of the aggregate configuration"  class="large">
        <figcaption>Configuration of the elastic filter</figcaption>
        </figure> 
    
8. Additionally define the boosting rules by clicking **Define** in the **Boosting** section.
9. In the **Additional settings** section, choose **Exclude already bought products**. If your company sells replenishable products, you can set exclusion for specific number of days, for example, exclude products bought not later than 30 days ago.
9. In the right upper corner, click **Save**.

## Check the use case set up on the Synerise Demo workspace
---
You can check the configuration of each step directly in our Synerise Demo workspace:
- [Aggregate returning last seen products](https://app.synerise.com/analytics/aggregates/1162c599-338f-32f7-ba20-b1bb64fcaed0)
- [Aggregate returning last 20 products added to cart](https://app.synerise.com/analytics-v2/aggregates/72e0076e-8076-38a5-8bc1-29c3aa9c8013)
- [AI Recommendation](https://app.synerise.com/ai-v2/recommendations/nNL1ec4aj19V)

If you’re our partner or client, you already have automatic access to the **Synerise Demo workspace (1590)**, where you can explore all the configured elements of this use case and copy them to your workspace.  

If you’re not a partner or client yet, we encourage you to fill out the contact [form](https://demo.synerise.com/request) to schedule a meeting with our representatives. They’ll be happy to show you how our demo works and discuss how you can apply this use case in your business. 

## Read more
---
- [Aggregates](/docs/analytics/aggregates)
- [Recommendations](/docs/ai-hub/recommendations-v2)
