Enrichmentactivity is an advanced activity that allows you to define additional data to process in your workflow.
Context of use
Enrichmentactivity is generally used following targeting activities or after importing a file and before activities that allow the use of targeted data.
This activity contains more advanced enrichment functions than the
Queryactivity. Some simple cases of enrichment can be directly performed in the Query activity .
Enrichmentactivity, you can leverage the inbound transition and configure the activity to complete the output transition with additional data. It allows to combine data coming from multiple sets, or to create links to a temporary resource.
To configure an
- Drag and drop anEnrichmentactivity into your workflow.
- Select the activity, then open it using the button from the quick actions that appear.
- If the activity has several inbound transitions, select thePrimary set. The additional data configured in this activity will be added to this primary set in the outbound transition.If the primary set already contains additional data, you can choose to keep them or to remove them. If you uncheck theKeep all additional data from the main setoption, only the additional data configured in theEnrichmentare kept in the outbound transition.
- If there are several inbound transitions, define relations between the primary set and the other inbound data in theAdvanced Relationstab of the activity. You can add several relations using theAdd elementbutton.When defining a new relation, select the set of inbound data that you want to link to the primary set. Then define the type of relation. Several types of relations are available, depending on the inbound data and your data model:
Once theCardinalityis defined, define aReconciliation criteria. TheSource expressionof the reconciliation criteria can be a field from the target resource, an expression or directly a value specified between quotes.Define aLabeland anIDthat will be easy to identify later in the workflow.You can only define relations between the primary set and the other inbound transitions connected to theEnrichmentactivity. For simpler cases aiming at defining relations with database resources, use a Reconciliation activity.
- 1 cardinality simple link: each record of the incoming data is associated to one and only one record from the primary set. Each record from the primary set has one associated record in the linked data.
- N cardinality collection link: 0, 1 or more (N) records from the linked data can be associated to 1 record of the primary set.
- 0 or 1 cardinality simple link: records from the primary set can be associated with 0 or 1 record from the linked data, but not more than one.
- Define the additional data from theAdditional datatab of the activity. You can define additional data (simple fields, aggregates and collections) related to the targeting dimension of the primary set or based on the links created in theAdvanced relationstab of theEnrichmentactivity.Consult the Enriching data section.
- Confirm the configuration of your activity and save your workflow.
The data is now available to use in the activities connected after the
Enrichment. For example, you can find it under the
Additional data (targetData)link of the personalization fields explorer in an email content.
Example: Enriching profile data with data contained in a file
This example shows how to enrich profile data with purchase data contained in a file. We consider here that the purchase data are stored in a third-party system. Each profile can have several purchases stored in the file. The final goal of the workflow is to send an email to the target profiles who have purchased at least two items to thank them for their loyalty.
The workflow is configured as follows:
- AQueryactivity that targets the profiles who will receive the message.
- ALoad fileactivity that loads the purchase data. For example:tcode;tdate;customer;product;tamount aze123;21/05/2017;firstname.lastname@example.org;TV;799 aze124;28/05/2017;email@example.com;Headphones;8 aze125;31/07/2017;firstname.lastname@example.org;Headphones;8 aze126;14/12/2017;email@example.com;Plastic Cover;4 aze127;02/01/2018;firstname.lastname@example.org;Case Cover;79 aze128;04/03/2017;email@example.com;Phone;149With this example file, we will use the email address to reconcile the data with the database profiles. You can also enable unique IDs as described in this document .
- AnEnrichmentactivity that creates a link between the transaction data loaded from the file and the profiles selected in theQuery. The link is defined in theAdvanced relationstab of the activity. The link is based on the transition coming from theLoad fileactivity. It uses the "email" field of the profile resource and the "customer" column of the imported file as reconciliation criteria.Once the link is created, two sets ofAdditional dataare added:
- A collection of two lines corresponding to the two last transactions of each profile. For this collection, the product name, the transaction date, and the price of the product are added as additional data. A descending sort is applied on the data. To create the collection, from theAdditional datatab:Select the link previously defined in theAdvanced relationstab of the activity.CheckCollectionand specify the number of lines to retrieve (2 in this example). In this screen, you can customize theAliasand theLabelof the collection. These values will be visible in the following activities of the workflow when referring to this collection.AsDatato keep for the collection, select the columns that will be used in the final delivery.Apply a descending sort on the transaction date to make sure to retrieve the latest transactions.
- An aggregate counting the total number of transactions for each profile. This aggregate will be used later to filter profiles that have at least two transactions recorded. To create the aggregate, from theAdditional datatab:Select the link previously defined in theAdvanced relationstab of the activity.SelectAggregate.AsDatato keep, define aCount Allaggregate. If you need, specify a custom alias to find it faster in the following activities.
- ASegmentationactivity with only one segment, that retrieves profiles of the initial target that have at least two transactions recorded. Profiles with only one transaction are excluded. To do that, the query of the segmentation is made on the aggregate defined previously.
- AnEmail deliveryactivity that uses the additional data defined in theEnrichmentto dynamically retrieve the two last purchases made by the profile. The additional data can be found in theAdditional data (TargetData)node when adding a personalization field.