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

# FACT-Finder campaigns

> Influence search results in a targeted way with feedback, redirect and advisor campaigns, on the hit list, the product detail view and in the basket.

> [!WARNING]
>
> **The direct connection is deprecated and no longer supported.** It is only available up to FactFinder version 6.9 and is neither maintained nor developed further by WEBSALE. For new integrations, use the FactFinder WebComponents according to the official FactFinder documentation. This page is intended for existing shops that still work with the direct connection.

A campaign intervenes in the search result, depending on what the customer searched for. If someone searches for a brand, its banner appears. If someone searches for "AGB" (terms and conditions), they land directly on the information page. And anyone searching for "Tischdecke" (tablecloth) is asked follow-up questions that lead them to a small, suitable selection.

WEBSALE supports three of the FACT-Finder campaign types:

| Type | Effect | Where it can be used |
| - | - | - |
| Feedback | shows banners, texts and highlighted products | Hit list, product detail view, basket |
| Redirect | sends the customer to a specific page | Hit list |
| Advisor | asks questions and leads to products via the answers | Hit list |

In all cases, the FACT-Finder search function is a prerequisite.

> [!WARNING]
>
> FACT-Finder can return several campaigns at the same time, including ones that are mutually exclusive, for example two redirects. They are delivered without prioritization. You should therefore define a ranking yourself when integrating them, for example via a free placeholder used to hide the remaining campaigns.

Guide: Integration of FACT-Finder

## The common structure

All three types are enclosed in the same way. The outer enclosure checks whether a campaign exists at all, the loop runs over all delivered campaigns, and inside it an enclosure decides on the type.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{E-Search_Campaign}
   {@E-Search_Campaign}

      {E-Search_CampaignType_Feedback}
         ...
      {/E-Search_CampaignType_Feedback}

   {/@E-Search_Campaign}
{/E-Search_Campaign}
```

Each campaign is first configured in FACT-Finder Management: one or more search terms as triggers, plus mode, start date and validity period.

## Feedback campaigns on the hit list

With these, you highlight product groups, for example with a banner, and at the same time determine which products appear first.

For this, "Campaign active on: Search result" must be selected in the FACT-Finder campaign manager. In "Pushed Products" mode, the selected products are placed before the result, mixed in, or replace it entirely.

The code belongs in the result template specified after `FactFinderTemplate` in the `shop.config`.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<!-- innerhalb des Formulars -->
{E-Search_Campaign}
   {@E-Search_Campaign}
      {E-Search_CampaignType_Feedback}

         <!-- Texte und Banner der Kampagne -->
         {@E-Search_CampaignFeedbackText}
            (ID ~E-Search_CampaignFeedbackText_Id~)
            ~E-Search_CampaignFeedbackText_Label~
            ~E-Search_CampaignFeedbackText~
         {/@E-Search_CampaignFeedbackText}

         <!-- die hervorgehobenen Produkte -->
         {@E-Search_CampaignFeedbackResult}
            {PR-AdvData(~E-Search_CampaignFeedbackResult_Index~)}
               ~PR-Name~
               <img src="~PR-Image~">
               ~PR-Price~ ~WS-CurrencySymbol~
            {/PR-AdvData(~E-Search_CampaignFeedbackResult_Index~)}
         {/@E-Search_CampaignFeedbackResult}

      {/E-Search_CampaignType_Feedback}
   {/@E-Search_Campaign}
{/E-Search_Campaign}
```

> [!NOTE]
>
> FACT-Finder only delivers the product index for each hit. `PR-AdvData()` uses it to fetch the product data from the shop, and all the usual product tags are available within this enclosure.

## Feedback campaigns on product and basket

On the product detail view and in the basket there is no search that could trigger a campaign. Here, the shop must query the campaign from FACT-Finder separately, via an external include with the appropriate parameters.

![Factfinder feedback campaign overall](https://mintcdn.com/websaleag-44ee7ea6/ZpqrUDlxS94uTw6k/images/factfinder_feedback_kampagne_gesamt.jpg?fit=max\&auto=format\&n=ZpqrUDlxS94uTw6k\&q=85\&s=9da79af7ecd16719fea6cbe7a9eafad8)

For example, if someone searches for the brand "Wintec", a title image for this brand can be displayed automatically.

| Location | Parameters |
| - | - |
| Product detail view | Subshop ID and the product number of the displayed product |
| Basket | Subshop ID and the product numbers of all products in the basket |

### Step 1: Assign the campaign template

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<ExternalSearch>
   ...
   FactFinderCampaignTemplate = incl_factfinder_campaign.htm
   ...
</ExternalSearch>
```

If the section does not exist yet, create it.

### Step 2: Create the campaign template

It contains the same code as above, only without the surrounding form.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{E-Search_Campaign}
   {@E-Search_Campaign}
      {E-Search_CampaignType_Feedback}

         {@E-Search_CampaignFeedbackText}
            (ID ~E-Search_CampaignFeedbackText_Id~)
            ~E-Search_CampaignFeedbackText_Label~
            ~E-Search_CampaignFeedbackText~
         {/@E-Search_CampaignFeedbackText}

         {@E-Search_CampaignFeedbackResult}
            {PR-AdvData(~E-Search_CampaignFeedbackResult_Index~)}
               ~PR-Name~
               <img src="~PR-Image~">
               ~PR-Price~ ~WS-CurrencySymbol~
            {/PR-AdvData(~E-Search_CampaignFeedbackResult_Index~)}
         {/@E-Search_CampaignFeedbackResult}

      {/E-Search_CampaignType_Feedback}
   {/@E-Search_Campaign}
{/E-Search_Campaign}
```

### Step 3: Query on the product detail view

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~WS-ExternInclude($URL-Homepage$/cgi/wsproductsearch/wsproductsearch.cgi?m=$WS-MallID$&s=$WS-ShopID$&ss=$WS-SubShopID$&wsps_act=productcampaign&wsps_pi=$PR-Number$)~
```

### Step 4: Query in the basket

Here the address must first be assembled, because a parameter has to be appended for each product in the basket.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~DC-FP2_reset~
~DC-FP2_append($URL-Homepage$/cgi/wsproductsearch/wsproductsearch.cgi)~
~DC-FP2_append(?m=$WS-MallID$&s=$WS-ShopID$&ss=$WS-SubShopID$&wsps_act=basketcampaign)~

{@BASKET-PR-Data}
   {PR-AdvData($BASKET-PR-ProdIndex$)}
      ~DC-FP2_append(&wsps_pi=$PR-Number$)~
   {/PR-AdvData($BASKET-PR-ProdIndex$)}
{/@BASKET-PR-Data}

~WS-DisableXSSProtectionOnce~
~WS-ExternInclude($DC-FP2$)~
```

> [!NOTE]
>
> The detour via `PR-AdvData()` is necessary because the basket holds the product index, but the campaign query expects the product number.

> [!WARNING]
>
> Without `WS-DisableXSSProtectionOnce`, the assembled address would be output HTML-encoded and the call would fail.

## Redirect campaigns

Certain search terms lead directly to a page of your shop. Anyone searching for "AGB" lands on the terms and conditions instead of an empty hit list.

You define the target in FACT-Finder Management. The code belongs in the result template.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{E-Search_Success}
   {E-Search_Campaign}
      {@E-Search_Campaign}
         {E-Search_CampaignType_Target}

            <script type="text/javascript">
               location.href = "~E-Search_CampaignTarget~";
            </script>

         {/E-Search_CampaignType_Target}
      {/@E-Search_Campaign}
   {/E-Search_Campaign}
{/E-Search_Success}
```

For a visible output instead of the immediate redirect, `~E-Search_CampaignTarget~` is available for the address and `~E-Search_CampaignTarget_Name~` for its label.

> [!WARNING]
>
> Do not place a redirect campaign inside `{E-Search_Result}`. This enclosure only applies if there is a hit, and that is usually exactly not the case with a redirect.

## Advisor campaigns

Instead of a hit list, the customer is asked a question. Behind each answer lies a product selection, and answers can lead to further questions. The result is a question tree that replicates the advice of a specialist salesperson.

> [!NOTE]
>
> Only the currently active question is ever returned. At the start, this is the first question of the tree. When the customer clicks an answer, the following question becomes the active one.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{E-Search_Campaign}
   {@E-Search_Campaign}
      {E-Search_CampaignType_Advisor}
         {@E-Search_CampaignAdvisor}

            <h2>~E-Search_CampaignAdvisor~</h2>

            {@E-Search_CampaignAdvisorItem}
               (ID ~E-Search_CampaignAdvisorItem_Id~)
               <a href="~E-Search_CampaignAdvisorItem_Link~">~E-Search_CampaignAdvisorItem~</a>
            {/@E-Search_CampaignAdvisorItem}

         {/@E-Search_CampaignAdvisor}
      {/E-Search_CampaignType_Advisor}
   {/@E-Search_Campaign}
{/E-Search_Campaign}
```

> [!WARNING]
>
> Advisor campaigns look like a filter group but behave differently: as soon as a question is active, all other filters are hidden. It is therefore better to display them in a separate area above the hit list rather than within the filters. Otherwise the deviating behavior confuses the customer.

## Finally: release

After integration in the shop, the campaigns still have to be released in the FACT-Finder campaign manager. Without this step, everything remains invisible without any recognizable error.

Reference: Tags for the FACT-Finder integration

## Related topics

* Guide: Integration of FACT-Finder
* Guide: FACT-Finder: Filters, sorting and navigation
* Guide: Integrating external content


## Related topics

- [Materials: FACT-Finder templates](https://dokumentation.websale.de/en/v8s/materialien/materialien-fact-finder-templates.md)
- [Integration of FACT-Finder](https://dokumentation.websale.de/en/v8s/integration-von-fact-finder/integration-von-fact-finder.md)
- [E-Search_ (campaigns)](https://dokumentation.websale.de/en/v8s/referenz/tags/e-search/kampagnen.md)
- [FACT-Finder: Filters, sorting and navigation](https://dokumentation.websale.de/en/v8s/integration-von-fact-finder/fact-finder-filter-sortierung-und-navigation.md)
- [E-Search_ (basics and result list)](https://dokumentation.websale.de/en/v8s/referenz/tags/e-search/grundlagen-und-ergebnisliste.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.