-
Re: Velocity Script returns the wrong values
Sanford Whiteman Jan 2, 2018 5:54 PM (in response to Shai Milbauer)Three danger zones are apparent here:
- You must emit a fully-formed <a> element from Velocity, but you are just including the opening tag.
- Nested #defines are not supported (actually, a single #define isn't supported for URLs, but it usually works)
- The code is longer than it needs to be, making debugging more difficult.
I shortened and simplified your code and remedied the above problems. Try this:
## Add Article1 URL for the following languages : #set( $Url = { "English" : "URL1", "Arabic" : "URL2", "Russian" : "URL3", "Spanish" : "URL4", "Chinese" : "URL5", "Japanese" : "URL6", "Korean" : "URL7", "Vietnamese" : "URL8", "India" : "URL9", "Ukraine" : "URL10" }) ##-------------------------------------------------------------------------- ## Edit the Month and Year in the UTM's (where it says ##EDIT-ME!!##) : #set( $ArticleUtmCampaign = "utm_campaign=Monthly_NL_January2018_leads" ) #set( $ArticleUtmCampaignIndia = "utm_campaign=Monthly_NL_January2018_India_leads" ) ##-------------------------------------------------------------------------- ## No Need To Edit Below Here!!!!!!! ## ## Do not edit this param : #define( $Article1Link ) <a href="http://${ArticleUrl}?utm_source=email&utm_medium=marketo&${ArticleUtmCampaign}" style="text-transform: capitalize; text-decoration:none;background:none;color:white;font-family:'Open Sans',Arial, Helvetica, sans-serif;font-size:16px;font-weight:normal;line-height:120%;text-transform:uppercase;margin:0px;" target="_blank" name="article1">Click to read article</a> #end ##-------------------------------------------------------------------------- #if ( $lead.Country == "India") #set( $ArticleUrl = $Url["India"] ) #set( $ArticleUtmCampaign = $ArticleUtmCampaignIndia ) #elseif ( $Url.containsKey($lead.Segmentation_Language_1014) ) #set( $ArticleUrl = $Url[$lead.Segmentation_Language_1014] ) #else #set( $ArticleUrl = $Url["English"] ) #end ${Article1Link}
-
Re: Velocity Script returns the wrong values
Shai Milbauer Jan 3, 2018 7:54 AM (in response to Sanford Whiteman)Hi Sanford Whiteman,
Thanks so much for your help!
The Newsletter Template contains 5 articles per language, for each a similar token. I've noticed that param no.5 is the one that repeats itself. Maybe it's a step closer to the solution (HTML attached).
1. The <a> tag is not fully formed, because the text is an other personalized token.I've also tried to close the tag for testing but still the problem remains.
3. Thanks for that! it really makes more sense :-)
-
Re: Velocity Script returns the wrong values
Sanford Whiteman Jan 3, 2018 9:48 PM (in response to Shai Milbauer)You'll definitely need to output the fully-formed <a> as part-Velocity, part-static (or part-other-token) links are not supported.
Not sure what you mean by "param no. 5"? Are you using the same variable names in any of your Velocity tokens? Because that will break link rendering. See this blog post (that example uses only one token but the same rule applies across tokens, since they share a context).
-
Re: Velocity Script returns the wrong values
Shai Milbauer Jan 4, 2018 7:34 AM (in response to Sanford Whiteman)Hi Sanford Whiteman,
when is said "param no. 5", i meant article no. 5... :-/
Our newsletter is always 5 articles long, for each article URL there's a different token.
The problem I've experienced was that all of the links pointed to the last article (article no. 5). In preview mode, it all works as expected.
Anyway, with your help, i've found a workaround :-)
I just created unique parameters for each token and didn't use the same param name in different tokens. Now it all works well.
BTW,
didnt closed the <a> tag in "define", but i close it in the HTML. Still works :-)
-
Re: Velocity Script returns the wrong values
Sanford Whiteman Jan 4, 2018 12:28 PM (in response to Shai Milbauer)Cool, not reusing VTL variables in links is key, as you can see!
P.S. That unclosed tag may not work permanently. Marketo's HTML lexer is pretty lazy -- it thinks <a:tag> is an <a>, which is actually really fortunate for some cases -- but if it ever gets tightened up, the link would break. Of course plenty of other things will probably break in the meantime.
-
-
-