Personalization

Content personalization is the process of tailoring content to individual users based on their interests, behavior, and other characteristics. On Lumen, we use the Liquid templating engine to create personalized content.

Liquid is a flexible and powerful templating engine that allows you to personalize your content based on various customer attributes and behavior data. You can use variables, operators, condition blocks, and other features to create dynamic and personalized content.

Customer variables

To include a customer attribute in your content, simply enclose the attribute name in double curly braces, like this: {{ attribute_name }}. This will dynamically insert the value of the attribute for each individual customer.

Any standard or custom customer attribute can be used in this way.

For example, if you want to display the customer's first name(standard attribute) and location (custom attribute), you can use the following example:

Hello {{ first_name }}, your location is {{ location }}

In case a customer attribute is not available, an empty string will be shown in its place. To avoid this, you can use a fallback mechanism to provide a default value.

Operators

Operators are used to perform operations on variables, such as comparing them or manipulating their values. Here are some common operators:

  • == - Equal to

  • != - Not equal to

  • < - Less than

  • > - Greater than

  • <= - Less than or equal to

  • >= - Greater than or equal to

For instance, to display a discount code for customers who have made a purchase in the last 30 days, you can write the following:

{% if order_count >= 5 %}
  Use discount code LAST30 for 30% off your next purchase!
{% endif %}

In this example, the if statement checks if the customer's custom attribute named order_count has a value greater than or equal to 5.

Condition blocks

You can use condition blocks to display different content to different users based on certain conditions. For example, you can use the following code to display a different message to new and returning customers:

{% if orders_count == 0 %}
    Welcome to our store!
{% else %}
    Welcome back to our store!
{% endif %}

Fallbacks and defaults

In some cases, you may want to provide a fallback value or a default value if a variable is not defined. For example:

Hello {{ first_name | default: "Valued customer" }}, your location is {{ location | default: "not available" }}

In this example, if the first_name attribute is not available, the default value "Valued customer" will be displayed instead. Similarly, if the location attribute is not available, the default value "not available" will be displayed.

Filters

Filters are used to modify the output of variables or perform specific tasks. For example, you can use the date filter to format a date variable or the capitalize filter to capitalize the first letter of a string.

Here's an example of using the date filter to display the current date:

Today is {{ "now" | date: "%A, %B %d, %Y" }}

Liquid has many other features that you can use to personalize your content on Lumen. If you want to learn more, check out the Liquid documentation: https://shopify.github.io/liquid.

Last updated