SOLVED

Email Variable to track in Velocity

Go to solution
Jayant_Singh
Level 3

Email Variable to track in Velocity

I have defined a variable within the email template and want to use that variable in velocity script. So, I am not sure about that email variable can be used in velocity or not?

 

Email Variable

Email variable name is email_variable
<meta class="mktoString" id="email_variable" mktoname="Button Link" default="mylink" mktomodulescope="true" />

 

Velocity Script code is

 

 

#if( $ObjectList.isEmpty() )
<a href="http://www.mywebsite.com?parameter=${email_variable}">read more</a>
#end

 

 

 

Business Goal- To enable email local variable edit section in Email when variable is used in VTL coding.

Jayant
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Variable to track in Velocity

Suggested method to use two velocity variable one in template level that will help to control the output but my purpose is to allow edit the variable value in email level as it offer when we create local variable in email template.

Although, velocity token can control output but not allow to edit variable at email level. To edit velocity variable value need to change the velocity token value each time which I want to avoid this limitations here.


It doesn't sound like you fully understood the setup.

 

The template would look like this:

 

{{my.beginConditionalOutputOrComment}}
<a href="http://www.mywebsite.com?parameter=${email_variable}">read more</a>
{{my.endConditionalOutputOrComment}}

 

 

  • The first Velocity token starts an #if condition
  • The second Velocity token #ends the #if condition.
  • So whether the variable is output is controlled by Velocity — controlled by whether the condition matches.
  • The value of the variable is still edited in the usual way.

This is actually a springboard to the much more advanced method I use myself, but you have to be an expert Velocity developer to implement and support that method in production. 

 

View solution in original post

8 REPLIES 8
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Variable to track in Velocity

Sorry, variables can't be used in this way.

Jayant_Singh
Level 3

Re: Email Variable to track in Velocity

Hi San,

May be my application is wrong. Could you please suggest possible way to achieve this business goal? or it has no options at all.

Jayant
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Variable to track in Velocity

You could have two Velocity {{my.tokens}} (one with the the #if and one with the #end) on either side of the variable in the template.

 

Velocity thus doesn't need to read the variable itself but still controls the output.

Jayant_Singh
Level 3

Re: Email Variable to track in Velocity

Suggested method to use two velocity variable one in template level that will help to control the output but my purpose is to allow edit the variable value in email level as it offer when we create local variable in email template.

Although, velocity token can control output but not allow to edit variable at email level. To edit velocity variable value need to change the velocity token value each time which I want to avoid this limitations here.

Jayant
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Variable to track in Velocity

Suggested method to use two velocity variable one in template level that will help to control the output but my purpose is to allow edit the variable value in email level as it offer when we create local variable in email template.

Although, velocity token can control output but not allow to edit variable at email level. To edit velocity variable value need to change the velocity token value each time which I want to avoid this limitations here.


It doesn't sound like you fully understood the setup.

 

The template would look like this:

 

{{my.beginConditionalOutputOrComment}}
<a href="http://www.mywebsite.com?parameter=${email_variable}">read more</a>
{{my.endConditionalOutputOrComment}}

 

 

  • The first Velocity token starts an #if condition
  • The second Velocity token #ends the #if condition.
  • So whether the variable is output is controlled by Velocity — controlled by whether the condition matches.
  • The value of the variable is still edited in the usual way.

This is actually a springboard to the much more advanced method I use myself, but you have to be an expert Velocity developer to implement and support that method in production. 

 

Jayant_Singh
Level 3

Re: Email Variable to track in Velocity

Thanks San! but, it seems to be someone has to be more expertise in VTL. Kindly, share any reference link to understand in depth with similar scenario. 

 

Jayant
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Variable to track in Velocity

The method we're discussing here isn't written up separately anywhere.  I write about Velocity topics on the blog, but also need to spend time on Marketo Forms JS and other areas to not have to narrow a focus. Eventually it'll all be dumped there.

 

I'm also working on a video training series for Velocity which will start from the beginner level and work up to at least this level. But there's no ETA on that... my new camera hasn't even arrived!

 

Also, in September at MOPsCON 2020 I'll be giving a talk on advanced content generation using Velocity, so you could sign up for that, but I don't think there's a site for it yet.

Jayant_Singh
Level 3

Re: Email Variable to track in Velocity

Wish you best of luck, Happy to see you in MOPsCON 2020!!!😊 

is the registration link are open now? 

I will love to join and read advanced content management method when you published it I will subscribe the blog.

Jayant