SOLVED

Email script sample that will make a certain email part visible to specific audience otherwise not visible

Go to solution
shaniala
Level 1

Email script sample that will make a certain email part visible to specific audience otherwise not visible

Hello, community, can you help me to create a email scripting that will show specific email part only to specific criteria, like for example if they are in country of Mexico they can see this email part but if not no content should be visible

2 ACCEPTED SOLUTIONS

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Email script sample that will make a certain email part visible to specific audience otherwise not visible

Absolutely, you can use the simple conditional statement for that. Here's a Marketo email velocity script that will show a specific email part only to records with Country = Mexico. You can also combine multiple conditions with AND (&&) and OR (||) based on the requirement.

 

#if ($lead.Country.equals("Mexico"))
  <div>This content will be visible to records with Country = Mexico/div>
#else
  <div>This content will be displayed to other countries.</div>
#end

 

Make sure you select the field you're referencing in the velocity script editor from the object tree on the right of the script editor.

View solution in original post

Jo_Pitts1
Level 10 - Community Advisor

Re: Email script sample that will make a certain email part visible to specific audience otherwise not visible

@SaurabhGoyal_GN ,

you're most of the way there, but you are making it too hard, and you've got a formal reference in the mix that you don't want.

 

I'd do it like this (let's call this token - my.showMexicoStart):

 

#set( $COUNTRY_CODE_FILTER = ["mx", "mexico"] )

#set( $country = $lead.Country.toLowerCase()) ## Removed formal reference.

#if(!$COUNTRY_CODE_FILTER.contains($country))

 

 

and then a second token (let's call this token - my.showAnythingEnd)

 

#end

 

The if statement happily spans two tokens, so you don't need to go through the process of re-evaluating.

 

You'll also notice that I called the second token a very generic name.  You can use this to end ANY of these types of conditional display tokens.

 

So, the first token goes above all the modules you only want to show to people in Mexico, and the second goes at the end of them.

 

Cheers

Jo

View solution in original post

6 REPLIES 6
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Email script sample that will make a certain email part visible to specific audience otherwise not visible

Absolutely, you can use the simple conditional statement for that. Here's a Marketo email velocity script that will show a specific email part only to records with Country = Mexico. You can also combine multiple conditions with AND (&&) and OR (||) based on the requirement.

 

#if ($lead.Country.equals("Mexico"))
  <div>This content will be visible to records with Country = Mexico/div>
#else
  <div>This content will be displayed to other countries.</div>
#end

 

Make sure you select the field you're referencing in the velocity script editor from the object tree on the right of the script editor.

Zoe_Forman
Level 9 - Community Advisor + Adobe Champion

Re: Email script sample that will make a certain email part visible to specific audience otherwise not visible

Hi @shaniala 
Another option to @Darshil_Shah1 is that you use dynamic content.

 

Use segmentation set up by region/country languages, and then you can change the text or image based on the segmentation.

Test and try both ways and see what works best for the company and Marketo instance set-up you have.
Thanks, Zoe

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Email script sample that will make a certain email part visible to specific audience otherwise not visible

Great suggestion, @Zoe_Forman! Additionally, there's a possibility to even reference the segmentation membership in the velocity, if OP would like to show/hide content based on segment membership via the velocity script as well. 

SaurabhGoyal_GN
Level 4

Re: Email script sample that will make a certain email part visible to specific audience otherwise not visible

Hi @shaniala - Alteratively to the solutions provided above, You can comment out the module based on some logic like shown below. 
1 - Create the below given token. (Make sure to check mark the fields in right pabe which you are going to use in script)

2 - Apply the token above and below of the module like shown in screenshot below. 

 

#set( $COUNTRY_CODE_FILTER = ["mx", "mexico"] )

#set( $country = ${lead.Country.toLowerCase()})

#if(!$COUNTRY_CODE_FILTER.contains($country))
  #if( !$inUnsupportedLangList )
    #set( $inUnsupportedLangList = true )
      <!--
  #else
    #set( $inUnsupportedLangList = false )
      -->
  #end
#end

 Screenshot 2024-04-23 at 2.06.19 PM.png

Please let me know if you have any questions on implementation. 

Jo_Pitts1
Level 10 - Community Advisor

Re: Email script sample that will make a certain email part visible to specific audience otherwise not visible

@SaurabhGoyal_GN ,

you're most of the way there, but you are making it too hard, and you've got a formal reference in the mix that you don't want.

 

I'd do it like this (let's call this token - my.showMexicoStart):

 

#set( $COUNTRY_CODE_FILTER = ["mx", "mexico"] )

#set( $country = $lead.Country.toLowerCase()) ## Removed formal reference.

#if(!$COUNTRY_CODE_FILTER.contains($country))

 

 

and then a second token (let's call this token - my.showAnythingEnd)

 

#end

 

The if statement happily spans two tokens, so you don't need to go through the process of re-evaluating.

 

You'll also notice that I called the second token a very generic name.  You can use this to end ANY of these types of conditional display tokens.

 

So, the first token goes above all the modules you only want to show to people in Mexico, and the second goes at the end of them.

 

Cheers

Jo

SaurabhGoyal_GN
Level 4

Re: Email script sample that will make a certain email part visible to specific audience otherwise not visible

Thanks @Jo_Pitts1, Thanks for optimizing my code. Your suggestion makes a lot of sense.