SOLVED

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

Go to solution
Ronn_Burner
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

Sanford Whiteman Can you please help me make this work?

I feel like the code below is precisely what you have advised me to do, however, since tests still display incorrectly as they have before. Obviously, I've done something wrong but I am unable to identify and correct it.

Please and thank you.

#set( $ISO8601WithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Los_Angeles") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601 = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
${display.list( $lead.entrySet(), "\u000a" )}
#if( !$lead.dMSSubscribedDate.isEmpty() )
#set( $caldMSSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.dMSSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end
#if( !$lead.cRMProSubscribedDate.isEmpty() )
#set( $calcRMProSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.cRMProSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$calcRMProSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end
#if( !$lead.bHPHSubscribedDate.isEmpty() )
#set( $calbHPHSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.bHPHSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$calbHPHSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end
#if( !$lead.autoCheckSubscribedDate.isEmpty() )
#set( $calautoCheckSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.autoCheckSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$calautoCheckSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end
#if( !$lead.oAPSubscribedDate.isEmpty() )
#set( $caloAPSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.oAPSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$caloAPSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end
#if( !$lead.dealerWebsitesSubscribedDate.isEmpty() )
#set( $caldealerWebsitesSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.dealerWebsitesSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$caldealerWebsitesSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end
#if( !$lead.cRMSubscribedDate.isEmpty() )
#set( $calcRMSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.cRMSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$calcRMSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end
#if( !$lead.maxDigitalSubscribedDate.isEmpty() )
#set( $calmaxDigitalSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.maxDigitalSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$calmaxDigitalSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end
#if( $lead.dMSSubscribedDate.equals("") )
Your DMS Subscribed is false.
#end
#if( $lead.cRMProSubscribedDate.equals("") )
Your CRM Subscribed is false.
#end
#if( $lead.bHPHSubscribedDate.equals("") )
Your BHPH Subscribed is false.
#end
#if( $lead.autoCheckSubscribedDate.equals("") )
Your AutoCheck Subscribed is false.
#end
#if( $lead.oAPSubscribedDate.equals("") )
Your OAP Subscribed is false.
#end
#if( $lead.dealerWebsitesSubscribedDate.equals("") )
Your Dealer Websites Subscribed is false.
#end
#if( $lead.cRMSubscribedDate.equals("") )
Your CRM Pro Subscribed is false.
#end
#if( $lead.maxDigitalSubscribedDate.equals("") )
Your Max Digital Subscribed is false.
#end
SanfordWhiteman
Level 10 - Community Moderator

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

You don't need to test all the code at once. Isolate a representative unit of code and test only that.

This opening snippet, using the first field, works for me:

#set( $ISO8601WithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Los_Angeles") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601 = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
${display.list( $lead.entrySet(), "\u000a" )}
#if( !$lead.dMSSubscribedDate.isEmpty() )
#set( $caldMSSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.dMSSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

If I set $lead.dMSSubscribedDate to 2019-12-05 03:00:00 (n.b. running this code at 2019-12-05T19:10:06Z, later on the same day) then I get the expected output:

You subscribed to Product X within the past 24 hours.

If I set $lead.dMSSubscribedDate to 2019-12-04 03:00:00 (one day earlier) then I get no output, also as expected.

Ronn_Burner
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

Thank you so much! That helped. So I tested meticulously, unit of code by unit of code, and then collectively a whole and in the preview-by-list mode it reflected all "true's" appropriately as well as all the "false's". That's a huge win as it clearly appears to be working perfectly.

That said, when I run a smart campaign and actually send that same email - it's blank. So not exactly working perfectly. Does this make sense to you and/or what can I do from here?

SanfordWhiteman
Level 10 - Community Moderator

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

What about when you right-click someone in the Lead Database, choose Marketing » Send Email?

Ronn_Burner
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

That worked - and is the below image. Progress!

pastedImage_1.png

Obviously, it can't display like this. I will play with this and test until I get to the desired result (2nd image below) but please let me know what you see clearly needs to be corrected and/or just any tips.

Ideally, I'd like to have a sentence or two accompanied by an image as seen below for each unit of code (product section) which comes from my original unique emails. Can I just cut and add the HTML to the "You subscribed to DMS within the past 24 hours." section? Which should work but is that the way to do it?

If you say, yes, am I crazy or does this mean this framework is 100% completed and ready to go?

PRODUCT 01 = True

pastedImage_2.png

PRODUCT 02 = False

pastedImage_2.png

SanfordWhiteman
Level 10 - Community Moderator

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

That worked - and is the below image. Progress!

OK, that means your Smart Campaign wasn't in the right place in the MA hierarchy and didn't have the token available. Make sure the Program w/the SC can see the token (as is the case w/all tokens).

Yes, you can add HTML where you currently have plain text. Velocity just outputs what you tell it to, it doesn't think about whether it has HTML tags or not.

Ronn_Burner
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

OK, that means your Smart Campaign wasn't in the right place in the MA hierarchy and didn't have the token available. Make sure the Program w/the SC can see the token (as is the case w/all tokens).

Oh my goodness. *slams face onto keyboard* You're absolutely right and such a rookie mistake! I obviously know that. I utilize dynamic tokens for utm parameters extensively throughout my dynamic programs. I cannot believe I didn't catch that. It's so obvious. Ugh! That was paralysis by analysis resulting from fear and pressure of trying to do VTL from a clean slate.

Yes, you can add HTML where you currently have plain text. Velocity just outputs what you tell it to, it doesn't think about whether it has HTML tags or not.

I just tested this is a couple spots and it rendered perfectly!

Thank you, Sanford! Truly. This entire lesson was invaluable and I will take it and the code with me and utilize it as much as possible. This is high level and super cool stuff! I cannot thank you enough for your time, patience and help. You're my hero!

SanfordWhiteman
Level 10 - Community Moderator

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

Awesome, Ronn. Glad we were both able to persevere. Could you mark one of my answers as Correct?  And also, if you don't already follow my blog, it's a good idea now that you're in the Velocity world.

Ronn_Burner
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

Hello Sanford - The VTL script we created here is working flawlessly - with the exception of one minor display error in the screenshot below. User error, no doubt. All the velocity script displays properly following this block of text - I just didn't show all of the rest as it's perfect. I have included the relevant top portion of the code below and hopefully, you are able to easily see why this is happening. Can you please tell me what I need to do so that does not happen and/or appear? Thanks!

pastedImage_1.png

#set( $ISO8601WithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Los_Angeles") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601 = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
${display.list( $lead.entrySet(), "\u000a" )}
#if( !$lead.dMSSubscribedDate.isEmpty() )
#set( $caldMSSubscribedDate = $convert.toCalendar(
$convert.parseDate(
$lead.dMSSubscribedDate,
$ISO8601WithSpace,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 )
<tbody>
<tr>
<td colspan="3" style="line-height: 1px; font-size: 1px;" height="${FreeText2Col-top-space}">&nbsp;</td>
</tr>
<tr>
<td class="block" width="290" valign="top" style="vertical-align:top;width:290px;">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="font-size:14px; color:${TextColor}; font-family:${TextFontFamily}; mso-line-height-rule: exactly; line-height:20px;text-align:left;" valign="top">
<div id="FreeText2ColLContent71732c78-1779-4a8b-a26b-7f22327f6ca2" class="mktoText" mktoname="FreeText2ColLContent">
<div>
<strong><span style="font-size: 18px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"></span></span></strong>
<strong><span style="font-size: 18px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"></span></span></strong>
<strong><span style="font-size: 18px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"></span></span></strong>
<strong><span style="font-size: 18px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"></span></span></strong>
<p><strong><span style="font-size: 18px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"></span></span></strong><br /></p>
<p><strong><span style="font-size: 18px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"></span></span></strong><strong><span style="font-size: 18px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"></span></span></strong><strong><span style="font-size: 18px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;">Dealertrack and RouteOne Applications</span></span></strong><span style="font-size: 14px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"><a href="https://{{my.LM1}}?utm_source={{my.UTMSource}}&amp;utm_medium=email&amp;utm_campaign={{my.UTMCampaign}}&amp;utm_content={{my.UTMcontentW1CTA2}}" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #007c89; text-decoration: underline;"><span style="color: #0000ff;"><em><strong></strong></em></span></a></span></span></p>
<p><span style="font-size: 14px; font-family: arial, helvetica, sans-serif;">No other system gives you access to more lenders. Simply structure all your finance deals and submit to your lenders and receive lender decisions without ever leaving <em><strong>DealerCenter</strong></em>.&nbsp;<span style="color: #0000ff;"><em><strong><a href="https://{{my.LM1}}?utm_source={{my.UTMSource}}&amp;utm_medium=email&amp;utm_campaign={{my.UTMCampaign}}&amp;utm_content={{my.UTMcontentW1CTA1}}" target="_blank" id="" style="color: #0000ff;">See how it works in this video!</a></strong></em></span></span></p>
<span style="font-size: 14px;"><span style="font-family: arial,helvetica neue,helvetica,sans-serif;"><a href="https://{{my.LM1}}?utm_source={{my.UTMSource}}&amp;utm_medium=email&amp;utm_campaign={{my.UTMCampaign}}&amp;utm_content={{my.UTMcontentW1CTA2}}" style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: #007c89; text-decoration: underline;"><span style="color: #0000ff;"><em><strong></strong></em></span></a></span></span>
</div>
</div> </td>
</tr>
</tbody>
</table> </td>
<td class="block" width="20" style="font-size:1px;line-height:1px;">&nbsp; </td>
<td class="block padding_top" width="290" valign="top" style="vertical-align:top;width:290px;">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="font-size:14px; color:${TextColor}; font-family:${TextFontFamily}; mso-line-height-rule: exactly; line-height:20px;text-align:left;" valign="top">
<div id="FreeText2ColRContent71732c78-1779-4a8b-a26b-7f22327f6ca2" class="mktoText" mktoname="FreeText2ColRContent">
<table style="width: 67px; height: 29px; margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td><img src="https://gallery.mailchimp.com/f60eb80b4f12731362cb001a7/images/9529e54f-4754-4ac4-ae2b-ab817bcbf026.png" alt="" constrain="true" imagepreview="false" width="280" height="202" border="" align="top" /><br /></td>
</tr>
</tbody>
</table>
<p></p>
</div> </td>
</tr>
</tbody>
</table> </td>
</tr>
#end
#end‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
SanfordWhiteman
Level 10 - Community Moderator

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

That's the debug output from

${display.list( $lead.entrySet(), "\u000a" )}