How to show or hide template blocks and sections based on dynamic variables (new editor)

read
Last updated at:

You will learn

Learn how to use the email template editor’s Show/Hide Logic feature to show a particular block or section only to certain email recipients. This feature allows you to target your email content based on information about your subscribers, so each recipient has a highly personalized marketing experience. In this article, you’ll learn how to use this feature in Klaviyo’s new template editor. 

Before you begin

Before you craft your email, make sure you have the data you need by following the guidelines below. In addition, learn how section-level Show/Hide Logic settings can interact with block-level show/hide settings in About display options (new editor)

Collect data

You can use show/hide conditions based on profile data in any Klaviyo email. You can use Klaviyo properties or custom profile properties; just make sure the data has been added to Klaviyo before you begin. Profile properties can be added in the following ways: 

Learn more about profile properties in Klaviyo. 

If your email is sent as part of an event-triggered flow (e.g., an abandoned cart or order confirmation flow), you can also show or hide blocks based on the details of that flow’s trigger event. So, in an abandoned cart flow with the trigger Started Checkout, you can build show/hide conditions based on a cart’s value or the specific items the customer added. Learn more about event variables.

Understand how data is stored

Before configuring your show/hide condition, check to see how your data is stored. There are five data types in Klaviyo: 

  • Text
  • Number
  • Date
  • Boolean
  • List

How your data is stored will influence which show/hide conditions will work for you. Learn how to identify data types in your own account.

Craft your message

The first step to adding show/hide conditions in a message is to build the email template. This section will walk through a specific example, but you can follow the same steps to set any block to display based on your own criteria.

For example, if your company sells leather bags, you may collect customer preferences for how they use their bags with a signup form, as shown below. 

A signup form in the Klaviyo form editor with options to select a preference for bag use

You can then display a different image based on your customer’s bag preference. For example, if the customer’s preference is “Work,” the bag will appear in an image next to a laptop. If the customer’s preference is “Outdoors,” the bag will appear near a scenic overlook on a hiking trail. 

  1. Create a campaign or flow message
  2. Add an image block
  3. Upload the work-related image to the block
  4. Click Display Options from the image block’s customization menu
  5. Click Create Logic
  6. Add this condition: person|lookup:'Bag Preference' == 'Work' 
  7. Click Save Changes 
  8. Click Done on the block 

This block will show only to people who have selected “Work” as their preference. 

Next, add in the travel-related image to a new block under the work-related image. Follow the same steps as before, but this time, use the condition person|lookup:'Bag Preference' == 'Outdoors'

This block will only show to people who have selected “Outdoors” as their preference. 

An image block set to show only to recipients who are interested in the Outdoors

Finally, add in an image to appear for anyone who hasn’t selected either “Work” or “Outdoors.” Use a more generic image, and this condition: person|lookup:'Bag Preference' != 'Work' and person|lookup:'Bag Preference' != 'Outdoors'

This block will show to people who have chosen something other than “Work” or “Outdoors,” or have never selected a preference. 

An image block set to show to recipients who aren't interested in using their bag for work or the outdoors

Once you’ve configured each of the blocks, preview your message using 3 profiles. These profiles should be subscribers who meet one of each of the image criteria:

  • Customer who chose“Outdoors” 
  • Customer who chose “Work”
  • And customers with no preference/other preference

You can use these steps to show or hide blocks based on any profile or event data in your account. 

Customize your show/hide conditions

Learn how to build custom show/hide conditions using the Conditional logic reference. This resource contains sample conditions, which you can customize using your own profile and event variables. Learn how to identify profile and event variables in your account below. 

Create a show/hide condition with profile data 

If you are building a show/hide condition based on a profile property, replace the sample variable from the tables in the Conditional logic reference (e.g., person|lookup:'Favorite Color') with your profile property. Use the format person|lookup:'PROPERTY_NAME' and replace PROPERTY_NAME with the name of your property. 

Alternatively, use the silhouette icon to open the Add personalization menu. Choose a property from the menu to add it to the text block. Then, copy the variable name from within the property. To identify the variable name, remove the curly brackets around the variable, as well as |default:'' at the end (if present), along with any other filters

For example, in the screenshot below, the full property is {{ person|lookup:"Accepts Marketing"|default:"" }}. The variable name is person|lookup:"Accepts Marketing", so select that portion to use in your show/hide condition. 

A profile property in a text block

Create a show/hide condition with event data

You can use event data to show or hide a block if your message is part of an event-triggered flow. Only data within the trigger event can be used in a show/hide condition. 

To identify event variables:

  1. From the template editor, click Preview and Test
  2. Under Preview data source, click Event
  3. From the dropdown menu, select the event that will trigger the message you’re building 
  4. Scroll through the Event properties to find the property you’d like to include 
  5. Click the property name to copy the variable 
  6. Paste the variable into a text block or text editor 
  7. Remove the curly brackets (i.e., {{ and }}) from around the variable, as well as any filters
  8. Use the variable that remains in your show/hide condition

In the screenshot below, you’ll see the variable tag {{ event|lookup:'Item Count' }}. You’ll only need the text event|lookup:'Item Count' for your show/hide condition. 

A profile property from event data

Additional resources

x
Was this article helpful?
29 out of 57 found this helpful