Hi there,
I am currently encountering a problem while trying to fetch a field value from a custom object to use it in an email.
Specifically, I am retrieving a string from the custom object to use as the value of a query parameter in the URL within the email.
Please refer to the VTL code below and the attached screenshot of the email.
ISSUE can be noticed at the bottom left of the screenshot.
I have already verified the value in the custom object and confirmed that there are no spaces included.
NOTE - I checked the value in CO, if that is having the spaces included but answer is NO. There is no spaces in the value on CO.
Looking forward for some insights here.
#set($listing = $sorter.sort(${listings_cList}, ["listing_registration_start_date_time:asc"]))
#if($list.listing_status_completed.equals('0'))
#set($listingtoken = $list.listing_token)
$listingtoken
#end
Solved! Go to Solution.
You have 4 spaces in front of the output! It’s right there in your code. So that’s the clear reason. VTL is always space-preserving.
As Darshil says, the approach you’re using with one part of an <a>
outside of the token isn’t supported anyway. Move everything inside the token.
Instead of adding the UTM to the URL, can you display it raw(just the UTM value) to see whether it has spaces? The VTL code you have mentioned in the question doesn't have the part where you’re adding the UTM from the CO record at the end of the URL.
@Darshil_Shah1 -
Here are the different screenshot, these may will provide the clearity on the problem.
Scrennshot 1 shows edit draft mode of the email - Behind the word "hyperlink" I have applied the URL, same as above the same.
Screenshot 2 shows the preview of the email, with URL in the left bottom.
Screenshot 3 shows the inspect element of the module.
Why don't you output the entire anchor tag using the velocity? You would lose on the tracking data if you don't fully-form and output the entire anchor tag (<a> through </a>) from the velocity.
I am using dynamic content as well, I do have different URL for different languages and text as well. If I will be going this way then I will have to write either a long VTL token or I will have to create 45 tokens as I have 45 different langauages.
Also, If I will be fetching end-to-end anchor tag from velocity, then I will have to make changes in email template as well because I want to use the URL on CTA module. For now, I have variables for CTA text and URL.
Any other way around?
You can create the entire module via the velocity script (including HTML), and reference the segment membership in the velocity to personalize the email content. You’d face the same issue (i.e., non-trackable links) if you use the velocity tokens in the email variables.
If you’re willing to sacrifice Clicked Link in Email, you can do what you’re currently attempting. It’s still not supported, though.
Otherwise, you’d have to do some much fancier code to use the module-level ${mktoVariable}
within Velocity.
You have 4 spaces in front of the output! It’s right there in your code. So that’s the clear reason. VTL is always space-preserving.
As Darshil says, the approach you’re using with one part of an <a>
outside of the token isn’t supported anyway. Move everything inside the token.