Adding Dynamic Content in Beefree for Klaviyo
This article applies to both versions of the builder in paid plans.
What are Display Conditions?
Display Conditions allow you to add conditional statements to rows within email and page designs.
These conditional statements are useful in the following scenarios:
- When the email or page should display a row and when it should not. An example of this is an email campaign for a fintech company that wants to send different promotional emails to couples with children and couples with pets. For couples with children, they want to advertise their savings account for future college expenses, and for couples with pets, they want to advertise their savings account as a more cost effective option to pet insurance. In this example, Display Conditions allows you to define the condition for displaying the row's content to either segment.
- Using Display Conditions for product and content loops. An example of this is an abandoned cart email that sends an email recipient a reminder that they left multiple items inside their cart. We will walk through this loop example later in this article.
Prerequisites
Prior to getting started with Display Conditions and Klaviyo, ensure you complete the following:
- Enable Display Conditions within Beefree: You need a Professional account or higher to enable Display Conditions. To activate the feature, navigate to your workspace settings, scroll down to Display conditions, and toggle the feature on. You can also toggle it off at any time.
- Obtain a Klaviyo API key: Take the steps outlined in the Obtain API credentials Klaviyo article to get your API key.
Exporting a Design to Klaviyo
Beefree includes a Klaviyo connector. This means that you can export your designs to Klaviyo directly. Follow the steps outlined in the Exporting to Klaviyo article if you have a Klaviyo API key.
If you do not have an API key, take the steps outlined in the Copy the HTML section of the Testing and exporting your emails with Beefree article to export your email design's HTML and paste it within Klaviyo.
Klaviyo Events and Profile Properties
Klaviyo collects client information that it calls Profile Properties. You can reference the full list of available properties within the the Klaviyo Profile Properties Reference documentation. The important thing to note about these properties is that they operate as unique information about a client that helps segment them and determine what type of content they should receive from an email campaign. For example, if it is International Favorite Color Day and you want to send one version of your email to folks who love green and another version to folks who love yellow, you can use their custom properties to identify if they have a favorite color on file, and if they do, which segment they belong in.
In the following image, you will see an example of a client profile within Klaviyo. This profile does have a custom property called “Favorite Color”. We will explore this custom property more later in this article when we walk through an example of how use Django to add conditional syntax within Beefree and export it to Klaviyo.
Klaviyo Hide/Show Conditions Option
Klaviyo’s version of Beefree’s Display Conditions are called “Hide/Show Conditions”. Klaviyo accepts event data and profile properties as variables for determining whether or not to display a certain row to an email recipient. Reference the Use conditionals in messages documentation to explore sample conditions that you can easily copy and paste into Beefree Display Conditions to get started with hiding and showing rows conditionally.
Learn more about Hide/Show Conditions.
Dynamic Content in Beefree to Hide or Show Rows in Klaviyo
In this section, we are going to walk through an example of how to use Display Conditions within Beefree to hide or show a row based on customer's custom properties within Klaviyo.
Show/Hide content example
For this example, the first row will be shown to the segment of individuals who have a Favorite Color property equal to “green” and it will not display for anyone else. The second row will be shown to the segment of individuals who have a Favorite Color property equal to “yellow” and will not display to anyone else.
Take the following steps to add "show/hide" Klaviyo syntax within Beefree and follow along with the example scenario:
-
Add your client data into Klaviyo and ensure the “Favorite Color” profile property is set for the clients you’d like to send this email to. You can create a new custom property if this one does not already exist within your Klaviyo account.
-
Log in to Beefree.
-
Navigate to Settings>General settings>Builder preferences and toggle on Display conditions.
-
Enter the email design that you'd like to add the "show/hide" syntax to.
-
Click on the row you’d like to display to folks with a favorite color of green.
A panel with Row Properties will open on the right-hand side of the screen. -
Scroll down to the Dynamic Content section and click Add condition.
Complete the requested information:
-
Name
-
Description
-
Before*
-
After*
-
*The syntax for the before condition is the following based on the Klaviyo documentation:
{% if person|lookup:'Favorite Color' == 'green' or 'green' in person|lookup:'Favorite Color' %}
*The syntax for the after condition is the following:
{% endif %}
-
Perform the same steps on the row with the content for folks with a favorite color equal to yellow. Note that the only change in the syntax from the previous step is to change "green" to "yellow".
-
Export your design to Klaviyo.
-
Use Klaviyo to send the email.
You'll notice the rows wrapped in the conditionals display a row's content based on the Favorite color property.
The following image shows the final result for an email sent to an individual in the "Favorite color = green" segment.
The following image shows the final result for an email sent to an individual in the "Favorite color = yellow" segment.
Dynamic Content in Beefree to Create Product Loops in Klaviyo
This section uses both Display Conditions and Merge Tags to achieve a dynamic content product loop using customer information within Klaviyo.
Important: The example detailed in this section leverages small scale JSON examples to perform the loop. The syntax outlined in this section is also compatible with large scale JSON examples. The only difference is that if you are working with a large quantity of data, you should use the Klaviyo API to automate adding the required data to your Klaviyo account. If you already have this data available in your Klaviyo account, you can skip the Loop Prerequisites portion of this section. The most important take away from this section is to ensure any JSON you do save within Klaviyo is saved as a List type.
Product Loop Example
In the following example, we will explore how to leverage both Display Conditions and Merge Tags within Beefree App to create a Product Loop. We will also explore how to add JSON as a custom profile property within Klaviyo as a prerequisite to setting up the loop. Take the steps outlined in the following sections to add product loop Klaviyo syntax within Beefree, and follow along with the example scenario.
Loop Prerequisites
Prior to adding the product loop syntax within Beefree, ensure you have a custom profile property for your customers within Klaviyo.
Take the following steps to achieve this:
-
Create a new List within Klaviyo. In this example, we created one called “Abandoned Cart”.
-
Click Import contacts to upload a .CSV file with your contacts.*
-
Confirm the information and click Next to complete the upload.
For this example, we are using the following JSON for a customer who loves yellow and added yellow clothing items to their cart before abandoning it.
[
{
"product_name": "Yellow t-shirt",
"price": 19.99,
"quantity": 1,
"image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3VM83dh9a-yuMH5-yu8jeQZK6-nHGAI2bKg&s=",
"product_url": "https://www.target.com/s/yellow+shirt"
},
{
"product_name": "Yellow shorts",
"price": 29.99,
"quantity": 2,
"image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQCEiM412YUpO0mou51izxter00hOoF9Cs2e0kKjJSCSVMdiLNEYbI-5h15OPznoANBd3A&usqp=CAU",
"product_url": "https://www.target.com/s/mens+yellow+shorts"
}
]
For this example, we are using the following JSON for a customer who loves green and added green clothing items to their cart before abandoning it.
[
{
"product_name": "Green t-shirt",
"price": 19.99,
"quantity": 1,
"image": "https://media.istockphoto.com/id/1346570499/photo/smiling-climate-activists-in-public-park.jpg?s=612x612&w=0&k=20&c=5RLd1Dr-zPsSzqn4eZX1rOeqQcstlrJW0cIlYMsCKRo=",
"product_url": "https://www.target.com/s/green+t+shirt"
},
{
"product_name": "Green shorts",
"price": 29.99,
"quantity": 2,
"image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSqrblpnHi7gldR9rjWB5-GfJNAi_VFsueGdQ&s",
"product_url": "https://www.target.com/s?searchTerm=green+shorts&tref=typeahead%7Cterm%7Cgreen+shorts%7C%7C%7Chistory"
}
]
*Ensure that your .CSV file has a similar structure as the one displayed below. The most important part of the .CSV file is the column called abandoned_cart with the JSON inside of the cells.
Ensure that you save your JSON as a List within Klaviyo so it registers the format correctly. The following image shows an example of this.
Now, it is time to head over to Beefree and add the Display Conditions and Merge Tags syntax to loop through the JSON within an email.
To achieve this loop, we need to take the following steps:
-
Create new Merge Tags within Beefree.
-
Add the correct syntax to those new Merge Tags based on the Klaviyo documentation.
-
Add syntax for dynamic images.
-
Add syntax for dynamic urls within the Button content block.
-
Add the Merge Tags inside the row.
-
Wrap the row with Display Conditions syntax.
We’re going to walk through the sub-steps for each of these steps in the following sections.
Create new Merge Tags within Beefree
Use the tag syntax examples from the Message personalization reference documentation as merge tag syntax within Beefree. Based on the JSON examples shared in the Loop Prerequisites section, we are going to create the following Merge Tags within Beefree.
You can copy and paste the syntax displayed in the image from the table below.
Merge Tag Name |
Syntax |
---|---|
Product Name |
{{ item.product_name }} |
Product Price |
{{ item.price | floatformat:2 }} |
Image source |
{{ item.image }} |
Item quantity |
{{ item.quantity }} |
Product url |
{{ item.product_url }} |
After we create these merge tags within the Workspace Settings, we'll navigate to the builder to start adding them to the email design.
Add syntax for dynamic images
To add the syntax for dynamic images, take the following steps:
-
Inside of the row you want to wrap with the Display Conditions, drag and drop an Image content block.
-
Click on the Image content block inside the builder.
-
Navigate to Content Properties.
-
Toggle on Dynamic image.
-
Paste {{ item.image }} inside the Dynamic url field.
The following image shows a visual example of how this should look within the builder.
Add syntax for dynamic urls within the Button content block
Take the following steps to add dynamic urls within the Button content block:
-
Drag and drop the Button content block onto the builder stage.
-
Navigate to Content Properties on the right-hand side of the screen.
-
Set the Link type to Open Web Page.
-
Paste {{ item.product_url }} inside the Url field.
The following image shows a visual example of how this should look within the builder.
Add the Merge Tags inside the row
Take the following steps to add Merge Tags within the row:
-
Drag and drop the paragraph content block onto the stage.
-
Inside the paragraph block add the text and merge tag you’d like to see within it. For example: “Quantity: Item quantity”. Item quantity in this example is the name of the merge tag that we made in the Create new Merge Tags within Beefree section.
-
Add the remaining Merge Tags created in the previous sections to the row.
The following image shows a visual example of how this should look within the builder once all the merge tags are added to the email design.
Wrap the row with Display Conditions syntax
The steps outlined in this section are what make the product loop possible. Take the following steps to wrap the row with the Display Conditions syntax:
-
Navigate to the Row Properties.
-
Scroll down until you access Display Conditions.
-
Click Add a condition.
-
Complete the required fields:
-
Name
-
Description
-
Before*
-
After*
-
You can copy and paste the syntax for the Before and After fields from the following snippets:
*Before syntax
{% for item in person|lookup:'abandoned_cart' %}
*After syntax
{% endfor %}
Once complete, the Display Conditions modal looks like the following:
Now that these steps are complete, you can take the steps outlined in Exporting a Design to Klaviyo to add your new email design to a Flow or Campaign within Klaviyo.
Once the design is in Klaviyo, we can send it to customers. The following image show the email result for the customer who added yellow clothing items to their shopping cart.
The following image show the email result for the customer who added green clothing items to their shopping cart.
HTML that Beefree Created
Reference the HTML Beefree created for this example to see how the syntax added through Merge Tags and Display Conditions looks within the HTML code.
Note: The syntax used throughout this example is specific to Klaviyo. Other sending platforms utilize their own syntax to achieve similar behaviors.
If you have any questions, feel free to contact us.
Comments
0 comments
Please sign in to leave a comment.