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:
- 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' %}
- Add orders_data:
{% for orders in orders_data | limit:10 %}
...
{% endfor %}orders_data
is a list of orders ordered bypurchase_date
, for more information see the article Filter Liquid outputs. - Enter the products field:
{% assign products_data = orders.products | sort: 'price' | reverse %}
- Products field is another list, it needs to be looped through:
{% for products in products_data %}
...
{% endfor %} - 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 %} - 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 %}