Forum Discussion
Using Liquid to identify users in a segment
I'd like to have an element of an email show or hide based on if a user is within a segment using - Is this possible with Liquid? I've been hitting a brick wall with this and any solution i've found seems unnecessary convoluted - Am I missing something here?
Thanks in advance!
2 Replies
- jamesyiSupporter
One way to use liquid for this use case is by using custom attributes filters within the segment. For example, if your segment contains the following filters: age >21, fav_num == 5, and fav_food == burgers, you can use
{% if {{custom_attribute.${age}}} > 21 and {{custom_attribute.${fav_num}}} == 5 and {{custom_attribute.${fav_food}}} == "burgers" %}
show element of email
{% endif %}
However this will only work if your segment contains custom attributes as filters.
See documentation below for supported liquid tags:
Supported personalization tags
If you use other filters (like sessions, demographic, etc), your best bet is using Audience Path and having different versions of email sent to different audiences.
Hope this helps!
- TedScottInfluencer
The easiest way to do this is add a custom attribute to users in your segment then use liquid to insert your content based on that attribute.
Related Content
- 11 months ago