> For the complete documentation index, see [llms.txt](https://docs.fact-finder.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fact-finder.com/integration/recommendation-engine-integration.md).

# Recommendation-Engine Integration

## Summary

Cross-selling and up-selling can help increase sales over time. The main challenge is identifying typical buying patterns.

The FactFinder Recommendation Engine learns which items are frequently purchased together. For example, a customer buying a mobile phone may also be interested in a charger or case; a customer buying an evening dress may also be interested in a matching necklace or handbag. The engine analyzes purchases in your shop to discover relationships between products and categories, so you can proactively recommend relevant items and increase basket size.

## Supplying the Recommendation Engine with Sales Data

In addition to the product data already available through the Search function, the Recommendation Engine requires sales information.

There are two basic options available for doing this:

* Send the data through the **Tracking interface**
* Make it available in **a file** that is submitted at specific intervals

### Tracking and Recommendation Engine

This is the recommended method because tracking integration also provides additional benefits, such as enhanced analytics. The Tracking interface is part of the standard integration, so there is typically no additional effort required.

A detailed description of the Tracking interface is available in the [Tracking documentation](/integration/tracking-interface.md). To supply sales data to the Recommendation Engine, integrate tracking at least through the `buy` event.

The drawback of this method is that sales data is only available from the time of integration. For a new setup, expect a short learning period. To mitigate this, you can provide historical sales data via an export file for initial training.

> **Note:** Tracking data must be prepared by Analytics before it can be used by the Recommendation Engine. The `WhatsHot` job then collects this data periodically (usually once a day) from Analytics and stores it in the `APP_RESOURCES/analytics` directory. The Recommendation Engine import works only if data is available.

### Export File

The same principles that apply to exporting product data also apply when creating this export file. For details, see [Record structure for export/import](/docs/import/ff-search-integration-how-to-optimize-your-datafeed.md).

A CSV file is the ideal format. The export must be a complete export—incremental deliveries are not supported. If the volume is large, limit the exported period to 6–12 months.

The file must contain the following information:

* **Timestamp** - date and time of purchase.
* **Product ID** - ID or article number of the purchased product. This identifier must also be present in the product data provided to the FactFinder Search tool. In the product data, this must be the field with the role `productNumber`.
* **Quantity** - quantity of the product that has been purchased.
* **Shopping Basket ID** - required to establish which products were purchased together. This ID must be unique per shopping cart. If it is missing or 0, the corresponding event is ignored.
* **User ID** - identifies the purchaser. If the user is logged in, use the shop’s user ID. If the shop supports guest checkout, use an ID that is unique to each purchase.

> **Note:** If variants exist in the product data (i.e., a `masterArticleNumber` exists), also pass the `masterId`. When a variant is purchased, the engine learns the connection to the master product.

*Export file example:*

```language-plaintext
Timestamp; ProductID; Amount; CartID; UserID
2009-03-26 00:08:10; 16041987; 1; 3880; 23
2009-03-26 00:08:10; 4582657; 1; 3880; 23
2009-03-26 00:08:10; 8954245; 1; 3880; 23
2009-03-26 00:28:25; 5659536; 2; 3881; 30
2009-03-26 00:08:10; 4582657; 1; 3882; 42
2009-03-26 00:28:25; 4571231; 1; 3883; 51
...
```

## Requesting Product Recommendations via REST

The REST API documentation is part of the search application and is available at \[your NG server]/fact-finder/swagger-ui.html. You can also access it here:

Swagger Link: <https://ng-demo.fact-finder.de/fact-finder/swagger-ui.html>

In addition to the parameter documentation, you can test requests and inspect the results directly. Because the documentation is built with Swagger, you can also use Swagger Codegen to generate a client.

Product recommendations are available through the `recommendation` method. You can trigger a sales data import through the `import` method.

## Product Comparison Integration

This module makes it easy to offer product comparison in your shop. FactFinder provides the relevant product information for each requested article number, along with the compared attributes, and your shop only needs to display them.

You can also emphasize selected attributes to draw the customer’s attention to them.

The REST API documentation is part of the search application and is available at \[your NG server]/fact-finder/swagger-ui.html. You can also access it here:

Swagger Link: <https://ng-demo.fact-finder.de/fact-finder/swagger-ui.html>

In addition to the parameter documentation, you can test requests and inspect the results directly. Because the documentation is built with Swagger, you can also use Swagger Codegen to generate a client.

Module data is retrieved via the `compareproducts` function.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fact-finder.com/integration/recommendation-engine-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
