> ## Documentation Index
> Fetch the complete documentation index at: https://help.maestra.io/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Create a Popular Products (Bestsellers) Algorithm

The Popular Products algorithm surfaces your bestsellers to shoppers across every channel — email, website widgets, and personalized pages. Maestra Platform ranks products first by the number of orders they receive, then breaks ties using product view counts, so the items that customers actually buy float to the top.

There are three variations of the algorithm, each tuned for a different use case:

<CardGroup cols={3}>
  <Card title="Popular Products" icon="fire">
    Site-wide bestsellers for both identified and anonymous shoppers.
  </Card>

  <Card title="Popular Products by Category" icon="folder-tree">
    Bestsellers calculated independently for each product category.
  </Card>

  <Card title="Popular Products in Viewed Categories" icon="eye">
    Bestsellers from the categories a customer browsed in their most recent session.
  </Card>
</CardGroup>

## Popular Products

A general bestsellers algorithm that recommends the most-ordered products across your entire catalog. Best suited for mass email campaigns and homepage blocks where you want to show universally appealing products.

| Property          | Value                               |
| ----------------- | ----------------------------------- |
| Algorithm type    | Personalized recommendations        |
| Audience          | Identified and anonymous customers  |
| Available in      | API (recommendation widgets), email |
| Recalculation     | Once per day                        |
| Limit per project | 40 algorithms                       |

**Recommended use cases**

* Mass email campaigns (newsletters, promotional blasts).
* Homepage product blocks where you want to surface bestsellers to every visitor.

**Automatic checks performed for each recommendation**

* Product is in stock in the customer's delivery zone.
* Product brand matches the customer's brand (for multi-brand projects).
* Products the customer has already purchased are excluded.

### How to set it up

<Steps>
  <Step title="Open the recommendations section">
    In Maestra Platform, go to **Personalization → Product recommendations** and click **Create algorithm**.
  </Step>

  <Step title="Select the algorithm type">
    Choose **Popular Products** from the list of available algorithm types.
  </Step>

  <Step title="Name the algorithm">
    Give the algorithm a descriptive name so you can find it later (for example, `Homepage bestsellers`) and continue.
  </Step>

  <Step title="Configure general settings">
    * **Recommend from** — optionally restrict the source pool to a product segment. If left empty, the algorithm draws from your full catalog.
    * **Consider product actions for the past** — the time window used to calculate popularity. You can choose any value between **1 and 180 days**. Shorter windows make the algorithm more reactive to current trends; longer windows produce more stable results.
  </Step>

  <Step title="Launch the algorithm">
    Click **Launch**. The algorithm appears in your list with its current status and the timestamp of its last update.
  </Step>
</Steps>

<Tip>
  For homepages and broad newsletters, a 30–60 day window typically gives the best balance between freshness and statistical reliability.
</Tip>

## Popular Products by Category

This variation calculates a separate bestsellers list for every product category in your catalog. Use it on category pages so that the products shown reflect what's selling within that category, not site-wide.

| Property          | Value                               |
| ----------------- | ----------------------------------- |
| Algorithm type    | Category recommendations            |
| Audience          | Identified and anonymous customers  |
| Available in      | API (recommendation widgets), email |
| Recalculation     | Once per day                        |
| Limit per project | 20 algorithms                       |

**Recommended use cases**

* Category landing pages on your website.
* Category-specific email blocks (for example, "Top sellers in Beauty").

**Automatic checks performed for each recommendation**

* Product is in stock in the customer's delivery zone.
* Product brand matches the customer's brand (for multi-brand projects).
* Products the customer has already purchased are excluded.

<Note>
  Because results are returned per category, the recommendation output is a collection of items keyed to the category the customer is viewing. When you integrate the widget on a category page, pass the current category so the algorithm returns the right list.
</Note>

### How to set it up

<Steps>
  <Step title="Select the algorithm type">
    From **Personalization → Product recommendations → Create algorithm**, choose **Popular Products by Category**.
  </Step>

  <Step title="Name the algorithm">
    Enter a name (for example, `Category page bestsellers`) and continue.
  </Step>

  <Step title="Configure general settings">
    * **Recommend from** — optionally restrict the source pool to a product segment.
    * **Consider product actions for the past** — the popularity window, from **1 to 180 days**.
  </Step>

  <Step title="Launch the algorithm">
    Click **Launch**. The algorithm will appear in your list with its status and last-update time.
  </Step>
</Steps>

## Popular Products in Viewed Categories (Last Session)

This variation looks at the categories a customer browsed during their most recent session, then evenly distributes bestseller recommendations across those categories. It's the algorithm to use for browse-abandonment scenarios — when you want to bring shoppers back with items related to whatever drew their interest last time.

| Property          | Value                                                   |
| ----------------- | ------------------------------------------------------- |
| Algorithm type    | Personalized recommendations                            |
| Audience          | Identified customers only                               |
| Available in      | API (recommendation widgets), email                     |
| Recalculation     | In real time, as the customer interacts with categories |
| Limit per project | 1 algorithm                                             |

**Recommended use cases**

* Browse-abandonment ("abandoned category view") email and on-site mechanics.
* Win-back triggers that reference the customer's most recent interest.

**Automatic checks performed for each recommendation**

* Product is in stock in the customer's delivery zone.
* Product brand matches the customer's brand. In multi-brand projects, the algorithm operates within a single brand scope and generates recommendations separately for each brand the customer visited in the latest session.
* Products the customer has already purchased are excluded.

<Warning>
  Because the algorithm relies on session-level browsing history, it works only for **identified customers** — anonymous visitors won't receive recommendations from it. Make sure your tracking identifies customers before they enter the relevant trigger flow.
</Warning>

### How the distribution works

If a customer viewed three categories in their last session, the algorithm splits the recommendation slots evenly across those three categories and fills each slot with that category's current bestsellers. This way, recommendations reflect the full breadth of the customer's recent interest rather than over-indexing on a single category.

### How to set it up

<Steps>
  <Step title="Select the algorithm type">
    From **Personalization → Product recommendations → Create algorithm**, choose **Popular Products in Viewed Categories (Last Session)**.
  </Step>

  <Step title="Name the algorithm">
    Enter a name (for example, `Browse abandonment bestsellers`) and continue.
  </Step>

  <Step title="Configure general settings">
    * **Recommend from** — optionally restrict the source pool to a product segment.
    * **Consider product actions for the past** — the popularity window, from **1 to 180 days**.
  </Step>

  <Step title="Launch the algorithm">
    Click **Launch**. Because the limit is one algorithm of this type per project, plan its configuration carefully before activating it.
  </Step>
</Steps>

## Choosing the right variation

<AccordionGroup>
  <Accordion title="Use Popular Products when…">
    You want a single bestsellers list for your whole catalog — for example, a homepage block, a generic "Top picks this week" newsletter, or any context where the customer hasn't given you a category signal.
  </Accordion>

  <Accordion title="Use Popular Products by Category when…">
    You're placing recommendations on a category page or inside a category-themed email. The customer's context already tells you which category to focus on, and you want the bestsellers from that slice.
  </Accordion>

  <Accordion title="Use Popular Products in Viewed Categories when…">
    You're building a browse-abandonment flow or any trigger that fires off a recent session. The customer has already shown interest in specific categories, and you want to bring them back with products tied to that interest.
  </Accordion>
</AccordionGroup>

## After launching

Once an algorithm is running, you can:

* Monitor its status and the timestamp of its last recalculation in the algorithm list.
* Plug it into a recommendation widget on your website via the API.
* Reference it inside email templates to render personalized blocks.
* Pause or edit it at any time — changes take effect on the next recalculation cycle (or in real time, for the viewed-categories variation).

<Tip>
  The daily recalculation for the first two variations runs automatically — there's no need to trigger it manually. If you need recommendations that react instantly to customer behavior, use the viewed-categories variation or combine bestsellers with other real-time algorithms.
</Tip>
