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.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
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.
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
@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.
@niteshpandey , when you have mentioned about dynamic HTML are you referring to the Personalization blocks. Please confirm
Views
Replies
Total Likes
Also, please can you explain about displayed in greed/red. I am not getting this point.
Thank you in advance
Views
Replies
Total Likes
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.
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
Views
Replies
Total Likes
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
Thank you for your reply @_Manoj_Kumar_ , I have a doubt here, why do i need to use an enrichment activity when I can load that data directly from add data option in the query activity and yes it has 1:1 link with the recipient table. Please can you explain the difference between these both.
Views
Replies
Total Likes
if & else if
condition fails when a recipient purchases only single feature and if that is in third place
first if will check if the condition is true and it will return that block but in my case it has to return the first feature block and 2nd feature block if the user has purchased the feature that is in 3rd feature block.
Best,
Revanth
Views
Replies
Total Likes
Views
Replies
Total Likes
Thank you for your reply @_Manoj_Kumar_ , I tried with if conditions only and then it started returning all the blocks instead of those blocks that needs to be returned.
Best,
Revanth
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies