x
You must have access to custom objects to use this functionality.
You will learn
Learn how to use custom objects in templates, so you can use object data in flow and campaign sends.
You must create an object first before you can use custom object data in templates.
Accessing object data through the personalization menuAccessing object data through the personalization menu
You can personalize text blocks in template editor using properties from a custom object, or the count of records for an object.
Learn how to use Klaviyo's template editor.
To get started with adding object data into your templates:
- Add a new text block or edit the text in an existing text block in your template.
- Select the Personalization button in the top right.
- In the personalization modal, select Objects from the All types dropdown.
- Within Objects, you’ll see all the objects on your account that you can use to pull data into the template. Select the object that contains the data you’d like to use in the template.
- Select the specific object property or object filter to include in the template. You can also create a new object filter here.
- Set the default text and any styles for your text.
To specify the capitalization rules for object data, you'll need to manually set the rule in the personalization tag. For example:
-
{{ object.full_name|title|default:'value' }}
John Doe -
{{ object.full_name|upper|default:'value' }}
JOHN DOE -
{{ object.full_name|lower|default:'value' }}
john doe
Learn more about modifying values with Django filters.
Accessing object data with personalization tagsAccessing object data with personalization tags
You can use personalization tags in emails (including the email’s subject line), SMS/MMS messages, push notifications, and Customer Hub to display object data.
Learn how to use personalization tags in Klaviyo.
Object personalization tag reference
You can use the following personalization tags with objects.
Using the object that triggered a flow
{{ object }} is only available when an object has triggered a flow.
These examples use the following:
- Object called Pet which is reference with the object tag in the template.
- Object property called Name
Structure | Example |
{{ object.object_property }} | {{ object.Name }} |
{{ object | lookup:'object_property' }} | {{ object | lookup:'Name' }} |
Getting an object by ID
These examples use the following:
- Object called Pet
- Object property called Name
- Event that triggered the flow with an object property called pet_id. This field is the same as the object ID for the Pet object.
Structure | Example |
{% customobject id={{ event.object_id }} as alias %} |
{% customobject id={{ event.pet_id }} as pet %} |
{% customobject id={{ event.object_id }} as alias %} |
{% customobject id={{ event.pet_id }} as pet %} |
Return a single object from an object filter
These examples use the following:
- An additional object filter called oldest_dog
- Object property called Name
Structure | Example |
{{ object_filter.object_filter_name.object_property}} | {{ object_filter.oldest_dog.Name }} |
{{ object_filter.object_filter_name | lookup: 'object_property' }} | {{ object_filter.oldest_dog | lookup: 'Name' }} |
Return a count
These examples use the following:
- Object called Pet
- An object filter called count_of_pets
Structure | Example |
{{ object.object_filter }} | {{ Pet.count_of_pets }} |
{{ object | lookup:'object_filter' }} | {{ Pet | lookup:'count_of_pets' }} |
Return a count from an object filter
These examples use the following:
- An additional object filter called count_of_dogs
Structure | Example |
{{ object_filter.object_filter_name }} | {{ object_filter.count_of_dogs }} |
Object data in show/hide logic
You can also configure whether to show or hide block in a template based on object data. Dynamically showing or hiding a block based on object data uses the same tags as the template builder. You can reference objects by ID, properties from object filters, or aggregates from object filters.
You must create object filters before you can reference them in show/hide logic.
For example, if you have a Pet object with a property called Breed, you can choose to only show a block to pet owners with a certain breed of dog using the object.Breed condition.
To set show/hide logic, click on the block you’d like to set the rules for and select Use code on the Display tab.
Enter the condition directly in the code editor.
Object filters
What is an object filter?What is an object filter?
Object filters enable you to limit the returned object records based on specific criteria you set so you can display records of a certain type.
Create a new object filterCreate a new object filter
To get started with creating an object filter:
- Add a new text block or edit the text in an existing text block in your template.
- Select the Personalization button.
- Within the personalization model, select Objects from the All types dropdown.
- Select the object that contains the data you’d like to set a filter for.
- Select the object property you’d like to set a filter for.
- Select Create new filter.
On the Create object filter modal, set the following information:
-
Name
Create a name for your object filter. -
Filter conditions
Define the rules an object must meet to be included in the text block. -
Behavior when multiple records meet the conditions
Define the behavior for cases where multiple records meet the conditions.
Once your object filter is created, you can use it in show/hide logic and personalization tags to display specific object records based on the criteria you set.
Additional resources