How do I apply personalization in my message?

You can personalize an email by adding a value from your database. For example, the first name or a salutation. You can apply any field you have as a database value in your campaign. If you use collections (a relational database), you can show more data in your message. Think of order information or account manager data.

Add personalization in text

Automatically add personalization

To add personalization, go to a text field and click on the person icon. Then choose the database field you wish to apply. The code will automatically be placed in the text.

Personalize.png

Example of name-based personalization:

Dear.png

You type the word Dear and the comma as your own text. The piece between the accolades is the personalized part. Spotler MailPro knows from the database what value to show for a contact. See the examples below for more personalization options.

 

Write your own personalization

Instead of automatically generating the code for the database fields, you can also write it yourself. This gives you a lot more options.
For this, you use the fieldname of the database field.

Personalization based on a databasefield value looks like this:

{{ contact.fieldname }}

 

If you have a database field with field name "first_name", and wish to show the value of the field, it would look like this:

{{ contact.first_name }}

 

When the database field isn't filled out for every contact, use a fallback value to prevent empty spaces in your text. You add a fallback or default value like this:

{{ contact.first_name|default('customer') }}

In this case, the personalized content will show "customer" when the first name of the contact is unknown.

 

You can also personalize based on date fields. Below, you find a few examples to show the date with different notations:

{{ contact.event_date }} --> 2024-01-01
{{ contact.event_date | date('d-m-Y') }} --> 01-01-2024
{{ contact.event_date | date('d F Y') }} --> 01 January 2024
{{ contact.event_date | format_date(locale='nl', dateFormat='long') }} --> 1 januari 2024
{{ contact.event_date | format_date(locale='nl', pattern='d MMM Y') }} --> 1 jan. 2024

 

Use the following code to only show a piece of text when the database field contains a value:

{% if contact.fieldname is not empty %}
[text]
{% endif %}

How these fields are populated is shown in the personalized preview.

Make sure to test your email thoroughly before definitively sending it, especially when using personalization.

You can find the full Twig documentation here: https://twig.symfony.com/.

 

Personalization based on collections

You can also use collections to personalize the text based on relational data.

When using a One to One (1:1) or One to many (1:n) relation, simply select or write the collection field you wish to show, like this:

{{ collection().adresses.street }}

In this example, we show a customer's full address:

example_personalization_1_1_collection.png

The result will look like this:

example_result_personalization_1_1_collection.png

When using a Many to one (n:1) relation, you can show all data from the collection, or use a filter to show specific collection items.

 

To show all items, select the collection field from the dropdown. Adjust the code as necessary. In the below example, the product names of all orders of a customer will be shown.

{% for key, orders in collection().orders %}
{{ orders.product_name}}
{% endfor %}

 

To show specific items from the collection, you use filters. First, create the filter. Use the gear icon to show the ID. You need the ID to build the code in the email. In the example below, we look up the ID of the filter "Order with furniture".

example_filter_show_ID.png

In the email, use the function collectionSearch() to look up all items matching a filter. Place the ID between the brackets. In the example below, the product names of all orders with furniture are being shown.

{% for key, collection in collectionSearch(406891) %}
{{ collection.order.product_name }}
{% endfor %}

The result will look something like this:

example_result_personalization_n_1_collection.png

Conditional content and conditional sendouts

In addition to applying personalization fields in your message, it is also possible to personalize using filters. We call this conditional content. Using this, you can only show a block of content or only send the email to the relevant audience. Read more about this in the article: How to personalize emails based on data in my database.