> 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/webcomponents-overview/web-components-4.x./guides/advanced/tracking-edge-cases.md).

# Tracking Edge Cases

Use discount prices correctly in FactFinder tracking requests.

### Discount Prices

If your shop offers discount prices, change the returned data to track the discount price instead of the normal price.

### The Problem

FactFinder uses `Field Roles` to identify the field that should be used for specific actions.

**Example Field Roles**

```javascript
{
    brand: "BrandFieldName",
    campaignProductNumber: "SomeIDField",
    deeplink: "DeeplinkField",
    description: "DescriptionField",
    displayProductNumber: "SomeIDField",
    ean: "TheEanField",
    imageUrl: "ImageUrlField",
    masterArticleNumber: "MasterArticleNumberField",
    price: "PriceField",
    productName: "NameField",
    trackingProductNumber: "SomeIdField"
}
```

Reading through the field roles, we can see that the field `PriceField` contains the price. FactFinder Web Components resolve fields when they prepare a tracking request or anything else that requires knowledge about specific parts of your data.

In the case of a discount price field, they would look up the wrong field because `discountPrice != price`.

### Using Discount Prices for Tracking Requests

Consider the following scenario:

Your product data contains two price fields: `price` and `discountPrice`. The `discountPrice` field contains `null` if no discount price is available. The field role looks like `"price": "price"`.

Write the discount price into the price field for proper tracking. To keep your `<ff-record-list>` templates simple, introduce a new field for displaying the price, such as `origPrice` or `displayPrice`.

```html
<script>
    document.addEventListener("ffReady", function (event) {
        const resultDispatcher = event.resultDispatcher;
        resultDispatcher.subscribe("records", function (records) {
            records.forEach(function (product) {
                product.record.origPrice = product.record.price;
                if (product.record.discountPrice !== null) {
                    product.record.price = product.record.discountPrice;
                }
            });                           
        });
    });
</script>
```

The template could look like:

```html
<ff-record-list>
    <ff-record>
        <span class="price">{{record.origPrice}}</span>
        {{#record.discountPrice}}
            <span class="discountStyle">{{record.discountPrice}}</span>
        {{/record.discountPrice}}
    </ff-record>
</ff-record-list>
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fact-finder.com/webcomponents-overview/web-components-4.x./guides/advanced/tracking-edge-cases.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
