# Manage campaign evaluation

> In the Campaign Evaluation section of your Application, you can decide the order, scope, and mode by which the Rule Engine evaluates your campaigns.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

:::note
To view the <CampaignEvaluation className="icon"/> **Campaign Evaluation** page and manage how
campaigns are evaluated, create at least two campaigns.
:::

Here, you can create evaluation groups, add campaigns into them, and select the evaluation
scope and evaluation mode by which triggered campaigns (campaigns that have at least one
successful [rule](/docs/product/rules/overview.md)) in each group are applied.

:::tip
After you set up the campaign evaluation page according to your campaign strategy,
[add each new campaign](/docs/product/campaigns/create-and-manage-campaigns.md#create-a-campaign-from-scratch)
to the correct campaign evaluation group. You should update the campaign evaluation tree
only if you change your strategy or add more use cases.
:::

Before you learn how to use this feature to, for example, control how your campaigns are
combined or prevent customers from obtaining rewards from several campaigns in the same
session, we recommend reading [Campaign evaluation](/docs/product/applications/evaluation-order-for-rules-and-filters.md) first.

## Create a campaign evaluation group

When you create an Application, the **base group** for campaign evaluation exists by default.
The [evaluation scope](#set-campaign-evaluation-mode) of the base group is set to
**session** and cannot be changed. Each campaign you create in the Application is
added to the base group by default unless you select a different group during
[campaign creation](/docs/product/campaigns/create-and-manage-campaigns.md#create-a-campaign-from-scratch)
or make another group the [default campaign evaluation group](#manage-campaign-evaluation-groups).

You can create evaluation groups on two levels:
- Within the base group.
- Within a group inside the base group.

For example, your campaign evaluation tree might look like this:

To create a campaign evaluation group:

1. In the <CampaignEvaluation className="icon"/> **Campaign Evaluation** section of your Application,
   on the right of the base group, click <VerticalMenu className="icon"/> > <Add className="icon"/> **Create group**.
2. In **Name**, type the name of the campaign evaluation group.
3. In **Description**, type a description of the group.
4. In **Evaluation scope**, select the [level](#set-campaign-evaluation-scope) on
   which the Rule Engine evaluates the campaigns within the group.
5. In **Evaluation mode**, select the [mode](#set-campaign-evaluation-mode) by which
   the Rule Engine evaluates the campaigns within the group.
6. Click **Create Group**.

:::tip
To create a group within a group (subgroup), on the right of the group, click <VerticalMenu className="icon"/> > <Add className="icon"/> **Create group inside**.
:::

## Set campaign evaluation scope

The evaluation scope determines the level on which the Rule Engine evaluates the campaigns
in that group. You can set the evaluation scope of each campaign evaluation group.

A group with the item scope that has [item campaigns](/docs/product/campaigns/overview#item-campaigns)
in it, for example, can apply effects from several campaigns to give a highest discount
value to each item in a session. Each cart item unit, however,
[can receive effects from only one campaign](#example-2-highest-discount-value-for-item-scope).

:::note
A campaign is triggered after its conditions are met, even if it returns no
effects.
:::

You can select one of the following evaluation scopes:

| <nobr>Evaluation scope</nobr>       | Description                                                                                                                           |     |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | --- |
| <Session className="icon"/> Session | Only customer sessions are considered when evaluating the campaigns. Groups with the session scope can contain campaigns of any type. |     |
| <Item className="icon"/> Item       | Only individual cart items are considered when evaluating the campaigns. Groups with the item scope can contain only item campaigns.  |     |

:::note
The campaign type is selected during [campaign creation](/docs/product/campaigns/create-and-manage-campaigns.md#create-a-campaign-from-scratch)
and cannot be changed.
:::

You can set the evaluation scope of a group in two ways:

- While [creating](#create-a-campaign-evaluation-group) or [editing](#manage-campaign-evaluation-groups)
  a group, in **Evaluation scope**, select the scope and save your changes.
- In the <VerticalMenu className="icon"/> menu of a group, click <Scope className="icon"/> **Set evaluation scope**,
  select the scope and save your changes.

## Set campaign evaluation mode

The evaluation mode determines how the Rule Engine evaluates the campaigns in that group.
You can set the evaluation mode of each campaign evaluation group.

All campaigns in a campaign evaluation group inherit the evaluation mode of the group,
meaning you cannot change the evaluation mode of individual campaigns.

:::important
Campaigns are evaluated from top to bottom in each group.
:::

You can select one of the following evaluation modes:

| Evaluation mode                                                               | Description                                                                                                                                                                                                                 |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <Stackable className="icon"/> Stackable                         | More than one triggered campaign can be applied. Triggered effects from campaigns stack up, meaning they can be combined.                                                                                                   |
| <nobr><First className="icon"/> First campaign</nobr>           | Only the first campaign in the group that is triggered is applied. More than one campaign can be applied if there are stackable evaluation groups inside the group, or if the evaluation scope of the group is set to item. |
| <nobr><Highest className="icon"/> Highest discount value</nobr> | Only the triggered campaign that provides the highest discount value is applied. More than one campaign can be applied if the evaluation scope of the group is set to item.                                                 |

You can set the evaluation mode of a group in two ways:

- While [creating](#create-a-campaign-evaluation-group) or [editing](#manage-campaign-evaluation-groups)
  a group, in **Evaluation mode**, select the mode, and save your changes.
- In the <VerticalMenu className="icon"/> menu of a group, click <Priority className="icon"/> **Set evaluation mode**,
  select the mode, and save your changes.

## Campaign evaluation mode examples

Let's take a look at a few examples that show how the different campaign evaluation modes
work.

### Example #1: Award multiple coupon discounts

Imagine we have the base group with three campaigns inside:

- **Campaign 1:** Gives a 10% discount on the total purchase if a valid first-time customer
  coupon code is redeemed.
- **Campaign 2:** Gives a 20% discount on the total purchase if a valid mid-season sale
  coupon code is redeemed.
- **Campaign 3:** Notifies anyone who completes an order about a future promotion.

We want to award customers who enter both a valid first-time customer coupon code and a
mid-season sale coupon code. We also want to notify them about a future promotion when they
complete their order.

To do that, we set the evaluation mode of the group to **stackable** (_Image 1_) so all
triggered campaigns in this case are applied. That means customers get a 30% discount on
the total purchase and are notified about a future promotion.

On the other hand, if we:

- Set the evaluation mode of the group to **first campaign** (_Image 2_), only the first
  triggered campaign in the group is applied. This means customers get a 10% discount only
  from the first-time customer code.
- Set the evaluation mode of the group to **highest discount value** (_Image 3_), only the
  triggered campaign that offers the highest discount value is applied, in this case,
  Campaign 2.

### Example #2: Award one coupon discount

Continuing from the previous example, say we want our customers to be able to redeem only
the coupon code that gives the highest discount value, but also be notified about a future
promotion.

To do this, we [create a group with the session scope](#create-a-campaign-evaluation-group)
that we name Group 1, and [we add](#manage-campaign-evaluation-groups) Campaign 1
and Campaign 2 to it. We set the evaluation mode of the base group to **stackable**,
and the evaluation mode of Group 1 to **highest discount value** (_Image 1_).

When customers now enter the two coupon codes, only the code that gives the highest
discount value is applied, but the customers are also notified of a future promotion.

If we also set the evaluation mode of the base group to **highest discount value** (_Image 2_),
the campaign that gives the highest discount value is applied, but customers aren't notified
about the future promotion.

### Example #3: Reward customers who shop from the mobile app

Imagine we also want to reward customers who shop from the store's mobile app, but we don't
want this deal to be combined with other deals. To do this, we add a fourth campaign to the
evaluation tree from the previous two examples:

- **Campaign 4:** Gives a 15% discount to customers who shop from the store's mobile app.
- **Group 1:** Contains Campaign 1 and Campaign 2, which give a 10% and a 20% discount on
  the total purchase if valid first-time customer and mid-season sale coupon codes are
  redeemed.
- **Campaign 3:** Notifies anyone who completes an order about a future promotion.

We ensure Campaign 4 is first in the base group, and we set the evaluation mode of the
base group to **first campaign** (_Image 1_). When our customers shop from the store's
mobile app, only Campaign 4 is applied as the first triggered campaign in the evaluation
tree.

On the other hand, if a customer shops from a web browser and doesn't redeem a coupon code,
the first triggered and applied campaign is Campaign 3 (_Image 2_).

### Example #4: Award the highest discount value

Let's imagine a different example where we have four campaigns that give discounts, and we
want to ensure our customers get the highest discount. Here is what our evaluation tree
looks like:

- **Campaign 1:** Gives a €10 discount on the total purchase.
- **Group 1:** Contains Campaign 2 and Campaign 3, which give a combined discount of €20 on
  the total purchase _only_ when applied together.
- **Group 2:** Contains Campaign 4, which gives a €12 discount on the total purchase, and
  Campaign 5, which gives a €15 discount.

We set the evaluation mode of the base group to **highest discount value**, the evaluation
mode of _Group 1_ to **stackable**, and the evaluation mode of _Group 2_ to **first campaign**
(_Image 1_). This ensures the Rule Engine only applies Campaign 2 and Campaign 3 to the
customers' orders since they give the highest discount of €20.

However, let's imagine a scenario where the two campaigns are not triggered together, but
Campaign 1, Campaign 4, and Campaign 5 are triggered (_Image 2_). In Group 2, the first
campaign of the two is applied. Although the €12 discount is not the higher discount value
of the two, the group considers its own evaluation mode first. Then, between Campaign 1
and Group 2, the €12 discount of Group 2 is applied.

## Highest discount value logic

The highest discount value mode can evaluate campaigns differently depending on the
[evaluation scope](#set-campaign-evaluation-scope) and the promotions involved.
Let's take a look at a few examples.

### Example #1: Highest discount value for session scope

Imagine we have a group with the evaluation scope set to **session** and the evaluation
mode set to **highest discount value**. The group has two [item campaigns](/docs/product/campaigns/overview#item-campaigns) inside:

- **Campaign 1:** Gives a 30% discount on a pair of sneakers and a pair of socks when
  bought together.
- **Campaign 2:** Gives a 10% discount on all items in the cart.

Our customer has a pair of sneakers, a pair of socks, and a t-shirt in their cart. Because
the evaluation scope is set to **session**, only one campaign can be applied. Campaign 1
offers the highest discount value, so it is the only applied campaign.

### Example #2: Highest discount value for item scope

Let's change the evaluation scope of the group from the previous example to **item**.
Now, only individual cart items are considered when evaluating the campaigns, so for a
pair of sneakers, a pair of socks, and a t-shirt in the cart, both campaigns are applied.

That means a 30% discount from Campaign 1 is applied to the pair of sneakers and pair of
socks, and a 10% discount from Campaign 2 is applied to the t-shirt.

Notice that no item in the cart is discounted more than once. Each individual cart item
unit can receive effects from only **one campaign**, ensuring that overlapping promotional
campaigns aren't combined.

### Example #3: Highest discount value for bundle promotions

Let's see what happens when choosing the highest discount value isn't as straightforward.

Imagine the following group with the evaluation scope set to **item** and the evaluation
mode set to **highest discount value**. The group has four [item campaigns](/docs/product/campaigns/overview#item-campaigns) inside:

- **Campaign 1:** Gives a 20% discount on a pair of sneakers and a t-shirt when bought
  together.
- **Campaign 2:** Gives a 30% discount on a pair of sneakers and a pair of socks when
  bought together.
- **Campaign 3:** Gives a $20 discount on a t-shirt and pair of socks when bought together.
- **Campaign 4:** Gives a 5% discount on all pairs of sneakers.

Our customer has a pair of sneakers, a pair of socks, and a t-shirt in their cart.

[Bundle promotions](/docs/product/rules/create-and-manage-bundles.md) are always
prioritized over non-bundle promotions. The highest discount value algorithm first solves
the overlapping bundle promotion conflict by identifying the bundle with the
**highest bundle discount margin**, calculated as the **total bundle discount value**
divided by the **total price of the bundle**.

In our case, Campaign 3 has the highest bundle discount margin, and a discount of $20 is
applied to the t-shirt and pair of socks. Because the evaluation scope is set to **item**,
and the sneakers are not discounted by Campaign 3, the 5% discount from Campaign 4 is
applied to the pair of sneakers as well.

## Manage campaign evaluation groups

In the <CampaignEvaluation className="icon"/> **Campaign Evaluation** section of your Application,
in the <VerticalMenu className="icon"/> menu of a group, you can perform a number of actions:

| Action                                                        | Description                                                                                                                                                                                                                                                               |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <nobr><Flag className="icon"/> Make group default</nobr>      | Make the group the default campaign evaluation group. This means new campaigns in the Application are added to this group by default unless you select a different group during campaign creation. You can do this only to a group that is not already the default group. |
| <nobr><Locked className="icon"/> Lock group</nobr>            | Lock the group to prevent adding and removing campaigns and groups. To allow this for a locked group, click <Unlocked className="icon"/> **Unlock group.** You cannot lock default groups.                                                                                |
| <nobr><Scope className="icon"/> Set evaluation scope</nobr>   | Set the [evaluation scope](#set-campaign-evaluation-scope) of the group.                                                                                                                                                                                              |
| <nobr><Priority className="icon"/> Set evaluation mode</nobr> | Set the [evaluation mode](#set-campaign-evaluation-mode) of the group.                                                                                                                                                                                                |
| <nobr><MoveUp className="icon"/> Make first</nobr>            | Make the group first in its parent group.                                                                                                                                                                                                                                 |
| <nobr><MoveDown className="icon"/> Make last</nobr>           | Make the group last in its parent group.                                                                                                                                                                                                                                  |
| <nobr><Group className="icon"/> Move to group</nobr>          | Move the group to another group. You can only move groups that don't contain other groups inside them.                                                                                                                                                                    |
| <nobr><Merge className="icon"/> Merge group with</nobr>       | Merge the group with another group to create one group that contains the contents of both groups. You cannot merge default groups.                                                                                                                                        |
| <nobr><Edit className="icon"/> Edit group</nobr>              | Change the name, description, evaluation scope, and evaluation mode of the group.                                                                                                                                                                                         |
| <nobr><Add className="icon"/> Create group inside</nobr>      | Create a group inside a group, also called a subgroup. Subgroups have their own evaluation mode and don't inherit the mode of their parent group.                                                                                                                         |
| <nobr><Ungroup className="icon"/> Ungroup campaigns</nobr>    | Ungroup the contents of the group. This dissolves the group and adds the campaigns and subgroups to the parent group.                                                                                                                                                     |

:::note
In the <VerticalMenu className="icon"/> menu of a campaign, you can make the campaign
first or last in its group, and move it to another group.
:::

:::tip Tips
- To change the order of groups and campaigns or move them elsewhere, you can also use the
  drag and drop action.
- In the top-right corner, you can undo or redo an action, cancel your changes, or save
  your changes to put them into effect.
- If you have a long expanded list of groups and campaigns, in the <VerticalMenu className="icon"/>
  menu of the base group, click <Collapse className="icon"/> **Collapse all groups** to
  collapse them. To view them all again, click <Expand className="icon"/> **Expand all groups**.
- To find a specific campaign, above the base group, in <Search className="icon"/> **Campaign name**,
  type the name of the campaign you want to find.
:::

## Filter campaigns by state

To filter campaigns by state:

1. In the <CampaignEvaluation className="icon"/> **Campaign Evaluation** section of your
   Application, click **State**.
2. Select one or more states to filter the list of groups and campaigns. See
   [campaign states](/docs/product/campaigns/overview#campaign-states) for more details.

## Related pages

- [Manage general settings](/docs/product/applications/manage-general-settings.md)
- [Manage campaign budgets](/docs/product/campaigns/settings/manage-campaign-budgets.md)
- [Evaluation order for rules and cart item filters](/docs/product/applications/evaluation-order-for-rules-and-filters.md)
