You are here:
Review Data in Marketing Cloud Engagement
After the segment is activated, a data extension is added to the Marketing Cloud Engagement business unit that you identified in the activation.
Here’s the data extension based on this activation use case.
| SubscriberKey | Id | FirstName | Loyalty_Program_Member |
|---|---|---|---|
| Raja_Jones_Push_123 | Raja_Jones_Push_123 | Raja | JSON BLOCK |
The first two columns are required based on the activation type (Push). The FirstName column is the selected direct attribute. The FirstName column is the selected direct attribute.
The last column contains the related attributes formatted as a JSON code block in one data extension field. The field is named after the API name of the related attribute's main DMO.
- Program Name
- Previous Loyalty Tier
- Loyalty Tier
These attributes are provided in the JSON code block.
[
{
"program_name": "Premiere Plus",
"Loyalty_Member_Tier": [
{
"previous_loyalty_tier": "Silver",
"loyalty_tier": "Gold"
}
]
}
]You can parse this data with either SSJS, AMPscript, or GTL. Here’s an example of parsing with SSJS.
<script runat="server">
Platform.Load("core","1");
//Get First Name from Data Extension
var First_Name = Platform.Recipient.GetAttributeValue("FirstName");
Variable.SetValue("@First_Name", First_Name);
//Get and Parse JSON Block from Data Extension
var JSONblock = Platform.Recipient.GetAttributeValue("Loyalty_Program_Member");
var JSONObj = Platform.Function.ParseJSON(JSONblock);
//Read JSON Block variables
Variable.SetValue("@program_name", JSONObj[0]["program_name"]);
Variable.SetValue("@loyalty_tier", JSONObj[0]["Loyalty_Member_Tier"][0]["loyalty_tier"]);
</script>
Congrats, %%=v(@First_Name)=%%!! You have recently reached %%=v(@loyalty_tier)=%% status
for %%=v(@program_name)=%%. To thank you for being such a loyal member with us,
we are giving you a $100 gift card for your favorite food delivery service!Here’s an example of parsing with AMPscript.
%%[
var @ProgramRowset, @ProgramRow, @ProgramName, @LoyaltyTierRowset, @LoyaltyTierRow, @LoyaltyTier
/* Query the first JSON object from the related attributes array. */
set @ProgramRowset=BuildRowsetFromJson(Loyalty_Program_Member,"$.[0]", false)
/* Get the program_name value. */
set @ProgramRow=row(@ProgramRowset, 1)
set @ProgramName=field(@ProgramRow, "program_name")
/* Query the first Loyalty_Member_Tier object inside of the first object. */
set @LoyaltyTierRowset=BuildRowsetFromJson(Loyalty_Program_Member,"$.[0]['Loyalty_Member_Tier'][0]", false)
/* Get the loyalty_tier value */
set @LoyaltyTierRow=row(@LoyaltyTierRowset, 1)
set @LoyaltyTier=field(@LoyaltyTierRow, "loyalty_tier")
/* Print the message */
OutputLine(concat("Congrats, ", FirstName, "!! You have recently reached ", @LoyaltyTier, " status
for ", @ProgramName, ". To thank you for being such a loyal member with us,
we are giving you a $100 gift card for your favorite food delivery service!"))
]%%

