-
Re: Dynamically Showing Module in Email Based on Segment
Floyd Alvares Nov 15, 2018 2:35 PM (in response to Bryan Epstein)Hi Bryan,
You cannot create dynamic modules per say only the sections within the module can be made dynamic.
Thanks
Floyd
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Nov 15, 2018 2:41 PM (in response to Floyd Alvares)Any suggestions for how to accommodate what we are looking to do?
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Nov 15, 2018 3:13 PM (in response to Bryan Epstein)4 of 4 people found this helpfulTwo Velocity tokens.
You wrap the section in these tokens (one before, one after).
The first token either outputs an open comment tag (<!--) or nothing, depending on the segment membership.
The second either outputs a close comment (-->) or nothing, according to the same rules.
Thus you can completely comment out a section (though it's still technically in the HTML, if that matters) removing it from the layout.
-
Re: Dynamically Showing Module in Email Based on Segment
Floyd Alvares Nov 15, 2018 3:17 PM (in response to Sanford Whiteman)Hi Sanford,
For my clarification, does this mean the email velocity tokens will be sitting inside the actual html in the email template?
Thanks
Floyd
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Nov 15, 2018 3:40 PM (in response to Floyd Alvares)Yes.
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Nov 15, 2018 3:55 PM (in response to Sanford Whiteman)How would utilizing velocity script enable me to do this? I understand the concept of commenting out the module. Essentially, we will need to comment out different modules based on about 8 different segments, so I want to make sure I understand the process of implementing this.
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Nov 15, 2018 4:06 PM (in response to Bryan Epstein)Velocity has access to all the lead's segment memberships. So it can conditionally output the comment wrappers, which in turn remove the content.
-
Re: Dynamically Showing Module in Email Based on Segment
Chris WilcoxNov 16, 2018 8:23 AM (in response to Bryan Epstein)
To elaborate on Sanford's idea (which is an very creative solution), you're going to write a velocity token that is essentially:
##HIDE SECTION FOR SEGMENTS #if (${lead.NAME_OF_SEGMENT_Segment__c} == "Value1" || ${lead.NAME_OF_SEGMENT_Segment__c} == "Value2") <!-- #else #end
This inserts the opening comment value for leads that have the segment value you want to hide the section for.
HOWEVER! Can I ask why you can't use a snippet or something to manage this? Is it a single section of the email that you need to either show/hide or modify based on the segment value? I'm not exactly understanding why it needs to be more complicated than a simple snippet that either shows content, or a blank line of HTML based on the value. More info would help me understand and maybe come up with another solution in addition to Sanford's.
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Nov 16, 2018 8:35 AM (in response to Chris Wilcox)There are about 10-15 segments in total that will be incorporated in this email with the dynamic content. The reason we couldn't use a snippet for this is because we would essentially have the email laid out in the following format laid out below.
There are three core sections of the email that would follow the criteria below.
- If person falls under criteria for Product A based on Segment, show SECTION A
Within each core section, there are additional sub-sections that would be accounted for dynamically. For instance:
PRODUCT A
- One column block for sub-section 1
- Two column block for sub-section 2
- One column block for sub-section 3
If we were to implement velocity scripts for these items, it looks like we would have to create the different layouts for each section to account for inserting each of the velocity scripts.
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Nov 16, 2018 11:38 AM (in response to Bryan Epstein)If we were to implement velocity scripts for these items, it looks like we would have to create the different layouts for each section to account for inserting each of the velocity scripts.
You mean if you were going to emit all the HTML from Velocity? Yes, that would require a... let's say, recontemplation of the email structure.
But just emitting the comments from Velocity doesn't require you to change anything.
-
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Nov 16, 2018 11:56 AM (in response to Chris Wilcox)I'd probably do this, but yep, that's the idea:
#set( $displayForSegments = ["SegmentName1","SegmentName2"] ) #if( $displayForSegments.contains($lead.Relevant_Segmentation_Field) ) <!-- #end
Remember that formal notation is discouraged anywhere but in output, because it breaks method chaining.
#if( ${lead.Relevant_Segmentation_Field}.isEmpty() ) ## syntax error
vs.
#if( $lead.Relevant_Segmentation_Field.isEmpty() ) ## good
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Dec 13, 2018 2:40 PM (in response to Sanford Whiteman)Sanford Whiteman - So I have been working on implementing this, and for some reason, the token is not commenting out the section that I am trying to hide.
#if (${lead.Segmentation_CompanyUpdateDRLTitle_1013} == "Default") <!-- #else #end
Since I am viewing the preview as a person that is part of the Default value of that segment, I am wondering if I am doing something that is causing a syntax error. Below is where the token is used in the email.
<!-- Company Update Title Module Begin--> {{my.Company-Update-Section-Begin}} <table class="mktoModule" mktoActive="true" mktoAddByDefault="true" id="Company-Update-Header" style=" -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-spacing: 0; border-collapse: collapse;" align="center" border="0" cellpadding="0" cellspacing="0" width="100%" mktoname="Company Update - Title"> <tr>
I have already removed all comments that were in the template that could possibly interfere with the implementation of this. Any thoughts?
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Dec 13, 2018 3:01 PM (in response to Bryan Epstein)Do you have the closing comment as well?
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Dec 13, 2018 4:15 PM (in response to Sanford Whiteman)Yes, I do. If I didn’t have —> to close the comment, it would hide everything up to wherever the next comment is. Unfortunately that is not the case here.
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Dec 13, 2018 4:24 PM (in response to Bryan Epstein)I'm not clear on what isn't happening. You need 2 tokens but I'm only seeing one; if you have 2, and they're both being output, then they will comment out whatever's in-between.
I also notice you're not using the code I recommended. ${formal} notation isn't for use in Velocity #if conditions, use $simple. Use formal only for output, and even then only when proven necessary, as it disrupts method chaining.
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Dec 13, 2018 4:48 PM (in response to Sanford Whiteman)I do have the ending comment in a token as well. So you would take out the { }? I will test tomorrow with that.
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Dec 14, 2018 5:20 AM (in response to Bryan Epstein)So here are my two tokens, but it doesn't seem to be working.
{{my.Company-Update-Section-Begin}}
#if ( $lead.Segmentation_CompanyUpdateDRLTitle_1013 == 'Default') <!-- #end
{{my.Company-Update-Section-End}}
#if ($lead.Segmentation_CompanyUpdateDRLTitle_1013 == 'Default') --> #else #end
Below is how the HTML looks (with the tables minimized). There are no comments within all of those individual modules.
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Dec 14, 2018 11:22 AM (in response to Bryan Epstein)First, how are you testing? You need to use Preview-by-List or send a real email (not sample) to test lead-senstive Velocity.
Second, if you're implying the #else condition is being met instead of the #if, can you put some debugging text in there to prove that conclusively? And also output $lead.Segmentation_CompanyUpdateDRLTitle_1013 to aid in debugging.
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Dec 14, 2018 12:49 PM (in response to Sanford Whiteman)I am testing using the preview-by-person. The issue that I am seeing currently is the following (and sorry if I am not explaining this right).
So I have the My.Tokens inserted into the areas of the template where they should be (between the respective modules necessary). When I create the email draft in the program where the tokens are, I am looking into the code of the email template, and it looks like all of the tokens within the <body> </body> have disappeared.
I think this could be what is causing the issue here.
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Dec 14, 2018 1:05 PM (in response to Bryan Epstein)Preview-by-List is the only preview you should trust for Velocity tokens.
When I create the email draft in the program where the tokens are, I am looking into the code of the email template, and it looks like all of the tokens within the <body> </body> have disappeared.
I think this could be what is causing the issue here.
If there aren't any tokens in the email anymore, yes, that would be a problem.
-
Re: Dynamically Showing Module in Email Based on Segment
Bryan Epstein Dec 14, 2018 1:38 PM (in response to Sanford Whiteman)Thanks for all of your help with this. I am thinking the main issue is that these tokens are disappearing, which I am not sure if you've ever run into that before (since it looks like my syntax should be correct with the velocity script token itself).
-
Re: Dynamically Showing Module in Email Based on Segment
Sanford Whiteman Dec 14, 2018 11:16 PM (in response to Bryan Epstein)...these tokens are disappearing, which I am not sure if you've ever run into that before...
No, not if they're there at the moment of approval. Is the same thing happening with non-Velocity {{my.tokens}} and with {{lead.tokens}} in the same section?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-