SOLVED

Re: Email Global variables with dynamic segmentation

Go to solution
Disha_Goyal6
Level 6

Hi @SanfordWhiteman,  I’m currently working with UTM parameters and assigning values using global variables in email editor 2.0. However, the client reported an issue where this approach doesn’t work when dynamic content (segmentation) is used. After doing some research and testing, I found that global variables are indeed not compatible with dynamic content.

 

Could you please suggest a workaround or an alternative approach to address this issue?

 

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

To use a global ${mktoVariable} in Dynamic Content:

 

  1. first output the ${mktoVariable} in-between 2 Velocity {{my.tokens}} with
    #define($mktoVariable_VTL)
    and
    #end
    respectively
  2. create a 3rd Velocity {{my.token}} that simply outputs
    ${mktoVariable_VTL}
  3. use that 3rd Velocity token in Dynamic Content

This is a very advanced use of Velocity in Marketo. Be sure you understand how Velocity scope & order-of-operations work before supporting it in a production environment.

View solution in original post

12 REPLIES 12
SanfordWhiteman
Level 10 - Community Moderator

To use a global ${mktoVariable} in Dynamic Content:

 

  1. first output the ${mktoVariable} in-between 2 Velocity {{my.tokens}} with
    #define($mktoVariable_VTL)
    and
    #end
    respectively
  2. create a 3rd Velocity {{my.token}} that simply outputs
    ${mktoVariable_VTL}
  3. use that 3rd Velocity token in Dynamic Content

This is a very advanced use of Velocity in Marketo. Be sure you understand how Velocity scope & order-of-operations work before supporting it in a production environment.

Disha_Goyal6
Level 6

Hi @SanfordWhiteman, how we will ge the value of modular email global variables in velocity token?

SanfordWhiteman
Level 10 - Community Moderator

What do you mean by “modular email global”? A global variable and a module-scoped variable are different.

Disha_Goyal6
Level 6

Hi @SanfordWhiteman, I am asking about these values that defined in global variable of email editr 2.0. 

Disha_Goyal6_0-1753331564527.png

 

These variables are not working with segmentation. So I did research but it is not supporting. I need a workaround if there is any.

 

SanfordWhiteman
Level 10 - Community Moderator

But I described how to do that above?

Disha_Goyal6
Level 6

Hi @SanfordWhiteman, I was applying the same method and added all the tokens in email. Iit is showing the variable as it is. No value is coming.

SanfordWhiteman
Level 10 - Community Moderator

Would need a detailed set of screenshots showing what you attempted.

Disha_Goyal6
Level 6

Hi @SanfordWhiteman, here is the screenshot of the velocity script tokens:

Disha_Goyal6_0-1753685700791.png

Disha_Goyal6_1-1753685717716.png

 

Disha_Goyal6_2-1753685749543.png

Added like this in Editor

Disha_Goyal6_3-1753685784368.png

Showing this output

Disha_Goyal6_4-1753685808164.png

 

I am not so proficient in Velocity script and I took help from chatgpt to implement the same.

 

 

 

SanfordWhiteman
Level 10 - Community Moderator

I am not so proficient in Velocity script and I took help from chatgpt to implement the same.


Well, that’s not going to work. ChatGPT is giving you broken code (as it usually does for Velocity tokens, not to mention infinite other areas). That’s why I mentioned you really have to understand Velocity to support this setup.

 

Again, the requirement is to output the ${mktoVariable} in-between Velocity {{my.tokens}}. It doesn’t go inside any Velocity token. If this still isn’t making sense it’s likely that you shouldn’t be putting this into prod.

Disha_Goyal6
Level 6

Hi @SanfordWhiteman, now I got your point and I added velocity script like this 
{{my.startDefine}}

${GA-initiative}

{{my.endDefine}}

{{my.Valueshow}}

 

Value appeared when we preview the email using dynamic segments. But, now I have one query here that value is not reflecting if we preview the email in preview mode.

Disha_Goyal6_0-1753789353234.png

 

Tags (1)
SanfordWhiteman
Level 10 - Community Moderator

Value appeared when we preview the email using dynamic segments. But, now I have one query here that value is not reflecting if we preview the email in preview mode.


You shouldn’t expect the Default preview to ever work with dynamic content.

Disha_Goyal6
Level 6

@SanfordWhiteman , thanks for your help.