Dynamically Showing Module in Email Based on Segment

Bryan_Epstein
Level 6

Dynamically Showing Module in Email Based on Segment

We are creating an email that will be full of dynamic content utilizing multiple segments. For this email, we would like for the default status to essentially hide the module completely. At this time, we can clear the content from the module, but not from the module itself.

Has anyone experienced anything similar to this or does anyone have a solution for how to resolve this?

23 REPLIES 23
Floyd_Alvares2
Level 8

Re: Dynamically Showing Module in Email Based on Segment

Hi Bryan,

You cannot create dynamic modules per say only the sections within the module can be made dynamic.

Thanks

Floyd

Bryan_Epstein
Level 6

Re: Dynamically Showing Module in Email Based on Segment

Any suggestions for how to accommodate what we are looking to do?

SanfordWhiteman
Level 10 - Community Moderator

Re: Dynamically Showing Module in Email Based on Segment

Two 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.

Floyd_Alvares2
Level 8

Re: Dynamically Showing Module in Email Based on Segment

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

SanfordWhiteman
Level 10 - Community Moderator

Re: Dynamically Showing Module in Email Based on Segment

Yes.

Bryan_Epstein
Level 6

Re: Dynamically Showing Module in Email Based on Segment

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.

SanfordWhiteman
Level 10 - Community Moderator

Re: Dynamically Showing Module in Email Based on Segment

Velocity has access to all the lead's segment memberships. So it can conditionally output the comment wrappers, which in turn remove the content.

Chris_Wilcox
Level 9

Re: Dynamically Showing Module in Email Based on Segment

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.

Bryan_Epstein
Level 6

Re: Dynamically Showing Module in Email Based on Segment

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.