# Conditional Based on Custom Field, for Email

**URL:** <https://community.hubspot.com/t/conditional-based-on-custom-field-for-email/95046>\
**Category:** Email Marketing Tool\
**Tags:** object, marketing-email\
**Created:** [November 29, 2023, 3:58pm UTC](https://community.hubspot.com/t/conditional-based-on-custom-field-for-email/95046 "2023-11-29T15:58:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Randi-E](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@Randi-E](https://community.hubspot.com/u/Randi-E)\
**Post date:** [November 29, 2023, 3:58pm UTC](https://community.hubspot.com/t/conditional-based-on-custom-field-for-email/95046/1 "2023-11-29T15:58:58Z")

</div>

Happy Holidays, HubSpot Users! I need your help.  
I am trying to set up a conditional in an email based on a custom field. The logic is that a different phrase and URL will appear if the customer field is equal to or contains specific text.  
So, if a person has DDR1 in that field, he/she/they see this: “Booking your next meeting with DDR1 is the perfect way to kickstart the upcoming year. (and this points to DDR1’s landing page).” And if a person has DDR2 in that field: “Booking your next meeting with DDR2 is the perfect way to kickstart the upcoming year. (and this points to DDR2’s landing page).” Then, a default message is sent if no one is assigned to them.

**There are multiple ways to get the DDRs’ names to appear, but I would like the specific URL piece to work because that is the point of most friction for our clients.**

Below are my initial passes, and I feel like I am just typing in something wrong or adding too many spaces or something…  
And the personalized token is set to show “thing1” or “thing2” if that custom field is empty.  
**ATTEMPT #1:** {% if contact.last\_provider\_seen == “DDR1” %} \<a href=“[https://awesome.com](https://awesome.com)” rel=“noopener”\>\<span style=“font-size: 18px; line-height: 125%; font-family: ‘Open Sans’, sans-serif; color: #0a148d; font-weight: bold;”\>Booking your next meeting with {{ personalization\_token(‘contact.last\_custom\_seen’, ‘thing1 or thing2’) }} is the perfect way to kickstart the upcoming year.\</span\>\</a\>], [personalization\_token(‘contact.last\_custom\_seen’ == “DDR2” %} \<a href=“[https://amazing.com](https://amazing.com)” rel=“noopener”\>\<span style=“font-size: 18px; line-height: 125%; font-family: ‘Open Sans’, sans-serif; color: #0a148d; font-weight: bold;”\>Booking your next meeting with {{ personalization\_token(‘contact.last\_custom\_seen’, ‘thing1 or thing2’) }} is the perfect way to kickstart the upcoming year.\</span\>\</a\>] {% else %} \<a href=“[https://homepage.com](https://homepage.com)” rel=“noopener”\>\<span style=“font-size: 18px; line-height: 125%; font-family: ‘Open Sans’, sans-serif; color: #0a148d; font-weight: bold;”\>Booking your next meeting with {{ personalization\_token(‘contact.last\_custom\_seen’, ‘thing1 or thing2’) }} is the perfect way to kickstart the upcoming year.\</span\>\</a\> {% endif %} \</span\>\</p\>

**ATTEMPT #2:** {% if [personalization\_token(‘contact.last\_provider\_seen’ == “DDR1” %} \<a href=“[https://awesome.com](https://awesome.com)” rel=“noopener”\>\<span style=“font-size: 18px; line-height: 125%; font-family: ‘Open Sans’, sans-serif; color: #0a148d; font-weight: bold;”\>Booking your next meeting with {{ personalization\_token(‘contact.last\_custom\_seen’, ‘thing1 or thing2’) }} is the perfect way to kickstart the upcoming year.\</span\>\</a\>], [personalization\_token(‘contact.last\_custom\_seen’ == “DDR2” %} \<a href=“[https://amazing.com](https://amazing.com)” rel=“noopener”\>\<span style=“font-size: 18px; line-height: 125%; font-family: ‘Open Sans’, sans-serif; color: #0a148d; font-weight: bold;”\>Booking your next meeting with {{ personalization\_token(‘contact.last\_custom\_seen’, ‘thing1 or thing2’) }} is the perfect way to kickstart the upcoming year.\</span\>\</a\>] {% else %} \<a href=“[https://homepage.com](https://homepage.com)” rel=“noopener”\>\<span style=“font-size: 18px; line-height: 125%; font-family: ‘Open Sans’, sans-serif; color: #0a148d; font-weight: bold;”\>Booking your next meeting with {{ personalization\_token(‘contact.last\_custom\_seen’, ‘thing1 or thing2’) }} is the perfect way to kickstart the upcoming year.\</span\>\</a\> {% endif %} \</span\>\</p\>

Cheers,  
Randi

---

<div class="post-metadata">

**Author:** ![karstenkoehler](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/karstenkoehler/32/68554_2.png) [@karstenkoehler](https://community.hubspot.com/u/karstenkoehler)\
**Post date:** [November 29, 2023, 4:02pm UTC](https://community.hubspot.com/t/conditional-based-on-custom-field-for-email/95046/2 "2023-11-29T16:02:10Z")

</div>

Hi @Randi-E,

HubSpot has an out of the box feature for this: smart rules. [Create and manage smart content rules](https://knowledge.hubspot.com/website-pages/create-and-manage-smart-content-rules)

From what you’re describing, it might solve what you’re trying to do.

Best regards!

---

<div class="post-metadata">

**Author:** ![Randi-E](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@Randi-E](https://community.hubspot.com/u/Randi-E)\
**Post date:** [November 30, 2023, 3:53pm UTC](https://community.hubspot.com/t/conditional-based-on-custom-field-for-email/95046/3 "2023-11-30T15:53:37Z")

</div>

Thanks so much for this tip, Karsten! It’s more direct and more likely to consistently work. Cheers!
