The following example illustrates adding different types of additional data to a query and its use as a personalization field in an email. For more on how to enrich the data targeted by a Query activity, refer to this section.
For this example, custom resources are used:
The objective is to send an email to the profiles for which at least one transaction has been saved. Via this email, the clients will receive a reminder of the last transaction carried out as well as an overview of all of their transactions: the number of products purchased, total spent, a reminder of the total number of loyalty points that they have accrued.
The workflow is presented as follows:
Add a Query activity, which allows you to target the profiles that have carried out at least one transaction.
From the query’s Additional data tab, define the different data to be displayed in the final email:
The simple field of the profile dimension corresponding to the loyalty points. Refer to the Adding a simple field section.
Two aggregates based on the transactions collection: the number of products purchased and the total amount spent. You can add them from the Data tab of the aggregate configuration window, using the Count and Sum aggregates. Refer to the Adding an aggregate section.
A collection returning the amount spent, the date, and the product of the last transaction effected.
To do this, you have to add the different fields that you want to display from the Data tab of the collection configuration window.
To return only the most recent transaction, you have to enter “1” for the Number of lines to return and apply a descending sort on the Date field of the collection from the Sort tab.
If you would like to check that the data is correctly transferred by the activity’s outbound transition, start the workflow for the first time (without the Email delivery activity) and open the query’s outbound transition.
Add an Email delivery activity. In the email content, insert the personalization fields corresponding to the data calculated in the query. You can find it via the Additional data (targetData) link of the personalization fields explorer.
Your workflow is now ready to be executed. The profiles targeted in the query will receive a personalized email containing the data calculated from their transactions.