Overview
We have updated the Activity API to allow users to include additional fields within activity_properties
. This enhancement enables users to define custom key-value pairs, ensuring a more personalized customer experience.
New Feature: Custom Fields in activity_properties
Users can now introduce their own keys within activity_properties
. This provides flexibility in tracking and storing relevant information for different business use cases. As demonstrated in the example below, we have added example_items
as a key with details like height, width
, product_name
, and base_price as values
Example: example_items Key
One such key is example_items
, an array you can use to pass a list of items with relevant details like image, name, quantity, prices, and other product-related attributes.
Step 1: Add example_items to Your API Payload
You can structure your API request like this:
Example Payload:
{
"key": "INSERT_YOUR_PUBLIC_KEY",
"activity_name": "cart_summary",
"user_properties": {
"email": "sampleuser@example.com",
"list_uuid": "INSERT_YOUR_LIST_UUID"
},
"activity_properties": {
"order_id": 99128,
"color": "blue",
"example_items": [
{
"product_image": "https://example.com/images/banner.jpg",
"product_name": "Custom Wall Banner",
"height": "6",
"width": "4",
"base_price": "18.00",
"printing_option": "Matte",
"printing_option_price": "3.50",
"hardware_option": "Hooks",
"hardware_price": "4.00",
"border_frame_option": "Black Frame",
"border_frame_price": "5.00",
"image_effect": "Sepia",
"minor_retouch_price": "2.00",
"quantity": 3,
"total_price_of_cart": "97.50"
}
]
}
}
💡Note: Only the example_items
array inside activity_properties
will be automatically replaced in the template. Other fields within activity_properties
will not be replaced automatically and can only be used in dropdown selections in templates.
Step 2: Update Your Template HTML
To ensure the dynamic content passed through the example_items array in the API is properly displayed in your BayEngage email, you'll need to update your HTML template using the Example Template HTML below. This syntax helps you loop through the list of items and automatically inject the data into the email for each recipient.
Important: Always wrap optional fields using {{#if}} ... {{/if}} blocks to ensure the template only shows fields that are actually present for that recipient.
💡 Why Use {{#if}}?
If the {{/if}} condition is not used in the template, the system will try to populate all possible fields for every user. So, if one user has 10 fields and another has only 8, the template will still try to fill all 10 fields, leaving the remaining 2 fields blank for the user with only 8 fields.
However, when {{/if}} is used around each field, the template will only display the fields that are actually available for that user. For example, if "base_price" is a field available for one user but not another, using the {{#if}} block ensures that this field is shown only for the user who has it, and skipped entirely for the one who doesn’t — avoiding any blank or empty placeholders in the output.
Example for {{/if}} :
{{#if minor_retouch_price}}
<li><strong>Minor Retouch Price:</strong> ${{minor_retouch_price}}</li>
{{/if}}
Example Template HTML
<table style="width: 100%; border-collapse: collapse; background:#F6F6F6">
<thead>
<tr style="border-bottom:1px solid #ccc;">
<th style="text-align: left; font-weight: bold; padding: 10px; border: 0;">Product Image</th>
<th style="text-align: left; font-weight: bold; padding: 10px; border: 0;">Product Name</th>
<th style="text-align: left; font-weight: bold; padding: 10px; border: 0;">Qty</th>
<th style="text-align: left; font-weight: bold; padding: 10px; border: 0;">Subtotal</th>
</tr>
</thead>
<tbody>
{{#each activity.cart_properties}}
<tr style="border-bottom:1px solid #ccc;">
<td style="padding: 10px; border: 0;"><img src="{{product_image}}" alt="{{product_name}}" style="max-width: 80px; height: auto;"></td>
<td style="padding: 10px; border: 0;"><p style="font-weight: bold; margin: 0; font-size:13px">{{product_name}}</p>
<ul style="padding: 0; margin: 5px 0; list-style-type: disc;">
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Size [H x W]:</strong> {{height}}" x {{width}}"</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Base Price:</strong> ${{base_price}}</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Printing Option:</strong> {{printing_option}} (${{printing_option_price}})</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Proof Request:</strong> Yes ($2.49)</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Hardware Option & Style:</strong> {{hardware_option}}</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Hardware Price:</strong> ${{hardware_price}}</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Border or Frame Option:</strong> {{border_frame_option}}</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Border or Frame Price:</strong> ${{border_frame_price}}</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Image Effects:</strong> {{image_effect}}</li>
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Minor Retouch Options:</strong> Enhance Color</li>
{{#if minor_retouch_price}}
<li style="font-size: 12px; margin-bottom: 5px;"><strong>Minor Retouch Price:</strong> ${{minor_retouch_price}}</li>
{{/if}}
</ul></td>
<td style="padding: 10px; border: 0; text-align: center;">{{quantity}}</td>
<td style="padding: 10px; border: 0; text-align: center;">${{total_price_of_cart}}</td>
</tr>
{{/each}}
</tbody>
</table>
Step 3: Add HTML to Your BayEngage Email Template
To use this in your campaign:
Open your email template inside the BayEngage editor.
Drag and drop the HTML block into your layout as shown in the screenshot below
Paste the customized HTML snippet shown above.
Save and preview as shown in the screenshot below
Once the email is triggered, it includes example_items. Based on your custom data, BayEngage will automatically populate the corresponding fields in the template.