Email Marketing Tool

Antonia
Participant

Use "IF" variable to check list membership and display smart content.

SOLVE

Hello,
i am trying to create an automated query of list memberships in a mail. The goal is that if a contact is in one of the lists, a specific link should be displayed.

I have 3 products with 10 risk classes each (30 lists). The case that a contact has a product with only one risk class can be displayed via smart content.

However, it is possible that a contact has a product several times with different risk classes. In this case smart content is of no use to me.
Therefore I want to create an automatic query of all list memberships in an e-mail.
This is the code:

<p>
{% if 881 in contact.list_memberships %}<a href="
http://test.de/i100.pdf"> Product 100 Infostuff</a><br>{% endif %}
{% if 880 in contact.list_memberships %}<a href="
http://test.de/i90.pdf"> Product 90 Infostuff</a><br>{% endif %}
{% if 879 in contact.list_memberships %}<a href="
http://test.de/i80.pdf"> Product 80 Infostuff</a><br>{% endif %}
{% if 878 in contact.list_memberships %}<a href="
http://test.de/i70.pdf"> Product 70 Infostuff</a><br>{% endif %} </p>

881-878 are the corresponding list IDs. 

This isnt working for me whatsoever. Any ideas how to solve this?

0 Upvotes
1 Accepted solution
Tnichs
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Use "IF" variable to check list membership and display smart content.

SOLVE
HI Antonia, when you have more complicated logic such as this, using a combination of lists are the way to do it as you can simplify the selection criteria. The trick here is to map out the logic outside of HubSpot first and then look at how to apply that using a combination of 'and' and 'or' statements. I've just done something very similar for a client using a combination of about 20 lists where there were multiple possibilities and variables. It's difficult to give an example without knowing your criteria fully. Happy to jump on a call to run through it if it helps. Drop me a PM and we can set that up.

klood digital, become the HubSpot Hero

View solution in original post

0 Upvotes
3 Replies 3
Tnichs
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Use "IF" variable to check list membership and display smart content.

SOLVE
HI Antonia possibly an easier way to achieve what you are looking to do is use a master list (a list of list memberships if you like) rather than try to write code in the email. So for example, you would create a list where the membership criteria is that they are either a member of list A or List B or List C (Or whichever logic you wish to use) Then you'd be able to use the smart content in the email based upon their membership of the master list Hope that makes sense. Trevor

klood digital, become the HubSpot Hero
Antonia
Participant

Use "IF" variable to check list membership and display smart content.

SOLVE

Hey Trevor, 

thanks for your suggestion. 
I do not see a solution using a master list since contacts can be in as much as 30 lists if they have all products in all risk classes. If i would use one master list as basis for my smart rules, it would always display the first matching criteria. But what if there are other matches - they are just not being displayed because hubspot would always grab the first?

0 Upvotes
Tnichs
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Use "IF" variable to check list membership and display smart content.

SOLVE
HI Antonia, when you have more complicated logic such as this, using a combination of lists are the way to do it as you can simplify the selection criteria. The trick here is to map out the logic outside of HubSpot first and then look at how to apply that using a combination of 'and' and 'or' statements. I've just done something very similar for a client using a combination of about 20 lists where there were multiple possibilities and variables. It's difficult to give an example without knowing your criteria fully. Happy to jump on a call to run through it if it helps. Drop me a PM and we can set that up.

klood digital, become the HubSpot Hero
0 Upvotes