It is an everyday use case to check if an event attribute value is present in other event attributes.
For example, if you have a purchase event with an attribute id that contains the id of purchase and a purchase_cancelled event that contains the same id of purchases that were canceled. To check the revenue from all purchase events that were not canceled, you need to exclude purchase ids stored in purchase_cancelled events. Here to exclude purchases with id 1234.
Another use case will be to select all unused issued voucher codes. There is a way to achieve this with definitions. Let's review an example setup based on voucher events step by step. In the example setup, the task is to select all unused voucher events. Imagine that you have the following events:
2 voucher events with different codes and status = assigned and 1 voucher event with status = used. Since, in this example, you want to fetch those voucher codes that were assigned to the customer but not used, you need to fetch the code attribute value from the voucher event that has the "code2" value stored in its code attribute. For that, you need to create 2 definitions:
- An event expression that would select all codes from voucher events with status used. That will create a list of all used codes.
- An aggregate that will select all unused vouchers.
The aggregate will store all unused vouchers.
That is the last step. Only two definitions - an event expression and customer aggregate are required for this use case. You can then see all unused voucher codes in the aggregate and use them in campaign personalization.