By using the rule type **Purchase History** you can target contacts based on their historical data. This could be actual “purchase history”, “behavior history” or any other event data that you have imported with the Purchase History import feature.

To create a segment matching a Purchase history event, click on the * +* (plus) icon and select

*in the add-pop up.*

**Purchase history**You'll then define your event type, whether you want to target contacts that have * purchased* or

*a purchase.*

**credited**On the segment workspace, you can select (in the right dropdown) to target contacts that have purchased/credited anything or specific items.

By clicking * Show more *you can specify:

**Item price**

If any/all/no item price is matching a specific value.**Total spent/credited**

If the total amount of an event matches a specific value.**Number of items****Timeframe**

When the event was registered (transaction time).

### Examples

To target contacts that **have purchased** the product *chocolate bar* at least once you can create a segment like this:

To target contacts that **have not purchased** any chocolate bars you keep the first statement (*Product is chocolate bar*), since that is still the row value you want to target, and then you to add* 0* (zero) to *number of items *under *Show more*:

In the example below, a contact should have purchased at least two items (not specified which items), to a total cost between 20 and 40 (your currency). And this purchase should have been made within the last seven days.

Here we want to target contacts that have purchased our top seller *SuperPhone 4* between 20-10 weeks ago but haven't bought anything since because we want to recommend some accessories suitable for a *SuperPhone 4*.

First, we need to add a criterion to find all contacts that have made the purchase. We do that by selecting a *specific item(s) *in the dropdown. And then point out which item by selecting the suitable Purchase history data attribute:

In the field *Other*, we can then add the timeframe:

Time for the second criteria, that no more purchases have been made after the main purchase. Here we don't specify a purchased item but simply target **any purchase **and combine that with** **the** total spent **should be **exactly 0 **(some currency).

We also add a timeframe, **after 20 weeks ago** (to cover all SuperPhone 4 purchases between 20-10 weeks ago):

And then, we're done! Or not really, it's time for testing!

## Calculating conditions

Purchase history conditions can be converted to a calculative rule.

By doing so your condition will expand and you'll be able to add the rows you want to include in your calculation.

In the top you'll set your main calculation and the result you want (e.g. A+B=2).

You can calculate using *addition, subtraction *or* division*.

**is / is not**The sum of the calculation is exactly the given number / The sum of the calculation is not the given number**is less than / is greater than**The sum of the calculation is smaller the given number (<X) / The sum of the calculation is bigger the given number (>X)**is at least / is at most**The sum of the calculation is smaller or equal to the given number (≤X) / The sum of the calculation is bigger or equal the given number (≥X)

Then you specify the values for A and B (and any timeframe for the transaction).

### Example

So, let's say our transactional data is structured as below image, with *TYPE* categorising the row (*bet* equals money in and *win* equals money out).

If we want to target players that have a gross gaming revenue (wins-bets) over 50, we add our main calcuation A minus B is greater than 50 in the top.

Then we specify A and B where we want the calculation to be based on the total amount (total price of all rows) that matches win (A) and bet (B) in the column *TYPE*.