> For the complete documentation index, see [llms.txt](https://help.openloyalty.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.openloyalty.io/campaigns/campaigns/campaigns-and-referral-campaigns/creating-campaigns/transaction-item-filters.md).

# Transaction Item Filters

Transaction Item Filters enable precise targeting within loyalty campaigns by allowing you to isolate specific products in a customer's purchase.

Transaction item filters are a powerful tool in Open Loyalty that allow you to **narrow down the list of products** included in a transaction before applying rules and effects. These filters work on the **line-item level** within a transaction - letting you isolate products based on attributes like category, price, quantity, brand, or custom values.

{% hint style="info" %}
Transaction item filters are now **Targets**. Each rule in the **Rules & Effects** step has a **Targets** row: a target is a named group of items in the transaction, and the rule's conditions and effects can refer to it. The condition picker no longer has a **Transaction filters** tab.
{% endhint %}

## How to Add a Target

{% stepper %}
{% step %}
In the **Rules & Effects** step of campaign creation, find the **Targets** row of the rule.\
![](https://2658975168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcNVX03KZzmrGwJihLiEx%2Fuploads%2Fgit-blob-4e4dda04392d726edb191130465f3611d050bb8f%2Fimage%20\(60\).png?alt=media)
{% endstep %}

{% step %}
Click **+ Add target**. A drawer opens with **Target name**, **Bundle** and **Target behavior**.
{% endstep %}

{% step %}
Under **Target behavior**, click **Add attribute** and choose an item attribute — for example category, SKU or brand.

<div align="left"><figure><img src="https://2658975168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcNVX03KZzmrGwJihLiEx%2Fuploads%2Fgit-blob-3c786fa1fda627db6d04474e24bebeced7e28504%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
Choose a **Condition** (for example **In**) and add the values. Pick values from your product catalog, or select **Enter data manually** for data that only arrives with the transaction. Add several attributes to narrow the selection further — all of them must match.
{% endstep %}

{% step %}
Name the target in **Target name** (it defaults to `Target 1`) and click **Save**.
{% endstep %}
{% endstepper %}

***

## How to Use Targets in Campaign Rules

Once you have defined a target, you can reference it in both **Conditions** and **Effects**:

### **In Conditions**

Conditions refer to a target through **Select target**. The condition picker groups conditions into **Popular conditions**, **Member details** and **Trigger-based conditions**. You can use a target to define conditions such as:

* the **quantity** of the items in the target
* the **value** of the items in the target

<figure><img src="https://2658975168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcNVX03KZzmrGwJihLiEx%2Fuploads%2Fgit-blob-4aea0d3dd5eb1200a06e1bb1034379b68b14d588%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

For example, set a rule to apply only if:

> Quantity of the items in target *Scenario 1* is greater than 3\
> Value of the items in target *Scenario 1* is at least 100 PLN

This allows for precise rule targeting.

### **In Effects**

In the **Add effect** drawer of an effect that awards units, choose the **Mode**:

* **Standard** — three fields:

  * **Applies to** (under **Target**) — the whole transaction, or one of the rule's targets. Set it to your target so that the effect rewards only the items in it.
  * **Calculate by** — **Flat amount**, **By quantity** or **By value**. **By complete bundle** is available for bundle targets: points are awarded per complete bundle, and an incomplete bundle earns nothing.
  * **Units** — the amount.

  The hint under the fields explains how the selected combination pays out.
* **Custom Expression** — the formula field, as before.

{% hint style="info" %}
**Standard** mode also attributes the points to exactly the products in **Applies to**, which is what [Product Analytics](/integrations-and-data-exchange/product-catalog/product-analytics.md) uses for each product's loyalty cost. Points from the whole transaction or from a custom expression are spread over all lines of the receipt in proportion to line value.
{% endhint %}

For example, set a rule to reward based on the following criteria:

> Give 1 point for every currency unit (e.g., for every dollar) spent on the items in the target.

#### Expressions

You can reference filtered items when defining custom effects using expressions like:

```javascript
agg(filter(transaction.items,'scenario_1')).sumBy('grossValue')
agg(filter(transaction.items,'scenario_1')).sumBy('qty')
```

These expressions:

* **Sum the gross value** or **quantity** of the items in the transaction that match the selected filter (`scenario_1`).
* Allow you to create advanced effects based on only a subset of items.

{% hint style="warning" %}
`scenario_1` is a dynamic identifier generated based on the filter name.

Always ensure the name you reference in your expression matches the transaction filter’s label.
{% endhint %}

You can also limit how much value or quantity is counted from each matching transaction item using a **cap**.

```javascript
(filter(transaction.items,'scenario_1')).sumBy('grossValue', 1)
(filter(transaction.items,'scenario_1')).sumBy('qty', 1)
```

**Examples:**

* `agg(filter(transaction.items,'filter_name')).sumBy('grossValue', 100)`\
  → Sums up `grossValue` per item, but caps each one at 100
* `agg(filter(transaction.items,'filter_name')).sumBy('qty', 2)`\
  → Counts quantity but caps it at 2 units per item

Use this when you want to prevent unusually high item values or quantities from impacting campaign conditions disproportionately.

## Summary

Targets help you build smarter, more targeted campaigns by focusing only on specific products within a transaction. You can:

* Define them once and reuse them in multiple rule conditions or effects.
* Create precise campaign logic based on filtered item sets.
* Use them to ensure bonuses or effects only apply to relevant items.


---

# 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://help.openloyalty.io/campaigns/campaigns/campaigns-and-referral-campaigns/creating-campaigns/transaction-item-filters.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.
