# And/Or Correlation Logic

Our triggers and segments are built using a rule builder. We define a set of conditions, rules, or criteria that we want to occur or that we want our players to satisfy. When these rules are satisfied, the trigger fires and segments are targeted.&#x20;

If we want to combine more than one condition, we need to join them together using the **AND or** **OR** **logic**. This tells the platform about the relationship between the conditions. Should they be grouped together or looked at in isolation?

## **And / Or Correlation Logic**

In order to combine several conditions together, we use the **AND or OR correlation logic** of the trigger or segment builder. This allows us to build more sophisticated triggers and segments.&#x20;

{% hint style="warning" %}
Remember to always check that you have chosen 'AND / OR' correctly as it will make a big difference to the expected behaviour of your trigger or segment.&#x20;
{% endhint %}

### ➕ AND Correlation Logic

By using the AND correlation logic you are asking for **all conditions to be satisfied in order for it to work**.&#x20;

**Example 1: Successful Deposit Trigger**

***I have a promotion planned where I want to offer all my players a bonus on their next successful deposit. I want to use a main trigger that will fire, my activity, on successful deposit to credit them a bonus.***

Here it's important to only trigger the activity when a player has an **approved deposit**. We need both of the conditions to be satisfied to ensure that we trigger at the correct moment.&#x20;

The payment transaction needs to satisfy two criteria:

1. The payment **type** must be a **deposit**\
   **AND**
2. The payment **status** must be **approved**

Therefore, the set-up should look like this:

![AND Correlation Logic](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGrxN2ttYCb8JwJc2TS%2F-MW4CKQcoOK4mThSSP9e%2F-MWUg0wiuDshWpVH3vSE%2FScreenshot%202021-03-18%20at%2013.35.28.png?alt=media\&token=74b625ea-b7d9-48bc-aecd-f3362413da36)

{% hint style="info" %}
🤔   **What if...**\
\
What if we used the OR correlation logic for this example?\
If we used the OR correlation logic, the activity would trigger when any player had either:

1. An approved payment (deposit or withdrawal)\
   **OR**
2. A deposit of any status (approved, rejected, or requested)

With this setup, we would be **incorrectly crediting bonuses** to players who satisfied **either** of the conditions in isolation. As an example, we would credit bonuses to players who had their **withdrawal approved** or even on **rejected deposits**. This is not only, not what we want to achieve but could also be a costly mistake.
{% endhint %}

### 🆚  OR Correlation Logic&#x20;

By using the **OR** **correlation logic** **only one of the conditions**, or group of conditions, must apply.&#x20;

**Example 2: A Segment for Internal Notifications to the CRM Team**

***I want to set up a notification to alert the CRM team when a player requests a withdrawal over €1000***

I want to create a segment including all the User IDs or email addresses of the CRM team. In this example, we need to use the OR correlation logic to ensure that, when the activity fires, it will target all the users listed in the conditions (it would be impossible for one user to satisfy all of the conditions).

We want the segment to include any of these conditions:

1. User ID 13\
   **OR**
2. User ID 14\
   **OR**
3. User ID 15

![OR Correlation Logic](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGrxN2ttYCb8JwJc2TS%2Fuploads%2FZvqYELqRX5ryduLk3Gbj%2FScreenshot%202024-04-01%20at%2015.55.25.png?alt=media\&token=6bdfb6e9-e8ce-46be-b02c-2a0603ef5ce7)

{% hint style="info" %}
🤔   **What if...**\
\
What if we used the AND correlation logic for this example?

If we used the AND correlation logic, the activity segment would look for users with the ID numbers 13, 14, and 15.&#x20;

As we know, it is not possible for a user to have more than one ID and therefore **there would be no players in the segment**.&#x20;
{% endhint %}

### ✅ **OR Correlation Logic Validation**&#x20;

As you may notice from the above picture, a validation message will automatically be displayed if you select the OR correlation logic from the trigger or segment builder. The message will remind you that the rule will fire when **any** conditions are met.

![Or condition validation](https://3654650655-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGrxN2ttYCb8JwJc2TS%2F-MW4CKQcoOK4mThSSP9e%2F-MWUgZzTBIBX-I4hjT-o%2FScreenshot%202021-03-22%20at%2011.07.17.png?alt=media\&token=59ce36b3-b9dd-4eba-a274-5e87e0015eac)

This validation message should be used as a final check of the conditions included in your trigger or segment to make sure everything is set up correctly and to avoid costly mistakes.&#x20;
