5 Replies Latest reply on Jan 4, 2018 12:28 PM by Sanford Whiteman

    Velocity Script returns the wrong values

    Shai Milbauer



      I'm using Velocity Scripting in our Newsletter in 10 different languages. 

      To make the tokens more convenient to fill (there are about 200 different values to change each month), I've chosen to use Velocity instead of the normal Dynamic Content.


      The template worked fine when I've created and tested it a couple of weeks ago, but now when I want to create the first newsletter to send the URL values are wrong.

      The wrong parameters are not in the wrong language and in the right token, but it's in the right language and i'm using it in a different token (article 5 token passes a couple of times for ex).

      It's important to add that the email preview by lead works as expected, and all other tokens except the URL ones are ok. The problem occurs in the actual send in the link tokens.


      In the script I'm defining variables for each language and another one for the link leader with http://, so i can track it. I suspect something has changed in the past weeks and the issue lies here.


      Anyone have any thoughts on what happened? It worked well a couple of weeks ago.

      Example script attached.

        • Re: Velocity Script returns the wrong values
          Sanford Whiteman

          Three danger zones are apparent here:


          1. You must emit a fully-formed <a> element from Velocity, but you are just including the opening tag.
          2. Nested #defines are not supported (actually, a single #define isn't supported for URLs, but it usually works)
          3. 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;" 
             name="article1">Click to read article</a>
          #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] )
          #set( $ArticleUrl = $Url["English"] )