HTML Email personalization | Community
Skip to main content
Level 5
November 27, 2023
Solved

HTML Email personalization

  • November 27, 2023
  • 2 replies
  • 2111 views

Hi team, 

 

I have an html email with 3 columns in it which are basically features, and there is a column in my custom schema that has feature values.

 

For ex: Feature_Desc (column name) and each recipient may have 1 feature , 2 features or 3 features. 

Recipient  Feature_Desc

recipient1 feature1

recipient2 feature1,feature2

recipient3 feature1,feature2, feature3

 

Is there a way that I can show only 1 column if they have purchased only feature1 and 2 columns if they have purchased 2 features. Please suggest.

 

Thank you in advance. 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Manoj_Kumar

Adding to this answer by @niteshpandey 

 

You can add checks like this:

<!DOCTYPE html> <html> <head> <style> /* Add your styles here */ .column { width: 33.33%; float: left; box-sizing: border-box; padding: 10px; } </style> </head> <body> <!-- Repeat the following block for each recipient --> <% if(targetData.feature1!=''){ %> <div class="column"> <h2>Recipient1</h2> <p>feature1</p> </div> <% } %> <% if(targetData.feature2!=''){ %> <div class="column"> <h2>Recipient2</h2> <p>feature1</p> <p>feature2</p> </div> <% } %> <% if(targetData.feature3!=''){ %> <div class="column"> <h2>Recipient3</h2> <p>feature1</p> <p>feature2</p> <p>feature3</p> </div> <% } %> <!-- End of recipient blocks --> </body> </html>

 

Notice the if conditions where we are checking if the value of the feature flag is available to not.

2 replies

Adobe Employee
November 27, 2023

Hi @rvnth ,
You can achieve this dynamic column display in your HTML email based on the number of features a recipient has purchased. One way to implement this is by using conditional logic in your email template.

To implement this in a more dynamic and automated way, you may need to generate the HTML content dynamically based on the actual data in your custom schema using XML that can be used in your email template environment.

 

Below is an example of how you can structure your HTML to handle varying numbers of features:

 

<!DOCTYPE html> <html> <head> <style> /* Add your styles here */ .column { width: 33.33%; float: left; box-sizing: border-box; padding: 10px; } </style> </head> <body> <!-- Repeat the following block for each recipient --> <div class="column"> <h2>Recipient1</h2> <p>feature1</p> </div> <div class="column"> <h2>Recipient2</h2> <p>feature1</p> <p>feature2</p> </div> <div class="column"> <h2>Recipient3</h2> <p>feature1</p> <p>feature2</p> <p>feature3</p> </div> <!-- End of recipient blocks --> </body> </html>

 

In this example, I've used CSS styling to create three columns. The recipient blocks are represented as <div> elements with the class "column". Inside each recipient block, you can dynamically include the features based on the recipient's purchase history.

rvnthAuthor
Level 5
November 27, 2023

Thank you @niteshpandey . Would I be able to cover the below scenario

 

For ex: if I have purchased 2 features called feature1 & feature 2, then the email should show up the feature3 that which I have not purchased. 

 

So, i will end up creating multiple if else statements including all possibilities. Please correct me if i am wrong.

Adobe Employee
November 27, 2023

@rvnth  You can perform a check for each feature to determine whether it has been purchased by the recipient. If the feature has been purchased, it's displayed in green; otherwise, it's displayed in red. You can dynamically generate columns based on the recipient's data.
This way, you don't need to create multiple if-else statements for each possibility, and it will be more scalable as you can easily add or remove features without modifying the code structure significantly.

Manoj_Kumar
Community Advisor
Manoj_KumarCommunity AdvisorAccepted solution
Community Advisor
November 28, 2023

Adding to this answer by @niteshpandey 

 

You can add checks like this:

<!DOCTYPE html> <html> <head> <style> /* Add your styles here */ .column { width: 33.33%; float: left; box-sizing: border-box; padding: 10px; } </style> </head> <body> <!-- Repeat the following block for each recipient --> <% if(targetData.feature1!=''){ %> <div class="column"> <h2>Recipient1</h2> <p>feature1</p> </div> <% } %> <% if(targetData.feature2!=''){ %> <div class="column"> <h2>Recipient2</h2> <p>feature1</p> <p>feature2</p> </div> <% } %> <% if(targetData.feature3!=''){ %> <div class="column"> <h2>Recipient3</h2> <p>feature1</p> <p>feature2</p> <p>feature3</p> </div> <% } %> <!-- End of recipient blocks --> </body> </html>

 

Notice the if conditions where we are checking if the value of the feature flag is available to not.

Manoj  | https://themartech.pro
rvnthAuthor
Level 5
November 28, 2023

Hi @_manoj_kumar_ ,

 

Here feature1 is the value of the column called feature_desc in a features schema. will that work if I use the targetdata.feature1!=''?

 

Please suggest. Thank you in advance

Manoj_Kumar
Community Advisor
Community Advisor
November 29, 2023

Hello @rvnth 

 

How the feature schema is linked with recipients? If it is 1:1 link then you can bring the field in targetdata via enrichment and use it like you mentioned

Manoj  | https://themartech.pro