Use liquid filters to display contact insight data information in a email

Learn about the filters you can use on your Liquid output to display insight data information.

Insight data information

Add insight data information to your liquid markup block:

  1. Use liquid to select a specific collection:
     {% assign orders_data = contact.insight.orders | sort: 'purchase_date' %}

    This snippet is using the contact scope, selecting insight data, for orders collection:

    contact.insight.orders

    This is sorts it by the purchase date:

    sort: 'purchase_date' %}
  2. Add orders_data:
      {% for orders in orders_data | limit:10 %}
    ...
    {% endfor %}
    orders_data is a list of orders ordered by purchase_date, for more information see the article Filter Liquid outputs.
  3. Enter the products field:
     {% assign products_data = orders.products | sort: 'price' | reverse %}
  4. Products field is another list, it needs to be looped through:
     {% for products in products_data %}
    ...
    {% endfor %}
  5. Show specific products data:
     <p>product price: {{products.price}}</p>

    Full code snippet example:

          {% assign orders_data = contact.insight.orders | sort: 'purchase_date'
          %}
    {% for orders in orders_data | limit:10 %}
    {% assign products_data = orders.products | sort: 'price' | reverse %}
    {% for products in products_data %}
    <p>product name: {{products.name}}</p>
    <p>product price: {{products.price}}</p>
    {% endfor %}
    {% endfor %}
  6. You can also include:
    <p>{{orders.purchase_date | date}}</p>
     {% assign orders_data = contact.insight.orders | sort: 'purchase_date' %}
    {% for orders in orders_data | limit:10 %}
    <p>{{orders.purchase_date | date}}</p>
    {% assign products_data = orders.products | sort: 'price' | reverse %}
    {% for products in products_data %}
    <p>product name: {{products.name}}</p>
    <p>product price: {{products.price}}</p>
    {% endfor %}
    {% endfor %}
Did you find this article helpful?

Can we help?

Thanks for using Dotdigital. If you need more help or support, then contact our support team.