Background: I have an email script that initializes a bunch of variables and then other smaller individual scripts that reference the initial variables. This works in the HTML email and plain text email, but there are 3 significant problems.
1. Where can I place my initial script token so that the other email scripts will populate in the subject line?
2. The initial email script token results in a lot of whitespace in the plain text version of the email. Since I have to place it at the very beginning of the email, the email has like 10 lines of whitespace at the top.
3. How do I properly create a link using an email script?
The way I have it now:
In the token:
#set ($directions = "https://google.com/maps/dir//Some+Place")
So here $directions is being printed — the actual link, that is.
In the HTML:
The error I get in Safari: (see attachment)
Solved! Go to Solution.
Yes, you'd have to find a way to make the inner text and/or elements generated in Velocity as well. Combining VTL-contributed HTML pieces (in token/s) with end-user-contributed pieces (in the email body itself, including in variables) is difficult-to-impossible.
A notable exception is using comment tokens (containing just the text "<!--" and "-->"), but that's for suppressing user content as opposed to merging VTL+user content in a functional way.
Standalone text or elements from each source can be combined, of course, but trying to construct <element>s from pieces of both is almost guaranteed to fail.
I've been able to fix #1 and #2, but #3 is still problematic! Any help/suggestions/followup is super, super appreciated!
For those who are interested...
#1 appeared to be a Marketo bug, because I can't trace how it was fixed.
#2 was fixed by including the initializing email script token in the subject line itself. Works like a charm.
#3 is still being a pain.
Always output a fully-formed A tag from Velocity. And within VTL, use the same rules as within email content: hard-code the https:// (don't have that in a VTL reference).
Excuse my ignorance, what does VTL stand for? Also, that won't work with the plain text version of the email though, correct?
Any way to get one token to populate a link in HTML and in plain text properly?
VTL = Velocity Template Language.
This might help: http://blog.teknkl.com/polymorphic-tokens/
I've been trying this, but I was getting another error. This might be something I'll to do in the future, but for now just to see how it works I'm trying to get the link to work in the plain text version of the email only. Still no luck.
where: $directions[$foreach.index] is equal to the string: "maps/dir//CNN+Center+Atlanta/"
In plain text email:
Error message is the same Safari error as the screenshot attached above.
Do you detect what I'm doing wrong?
Edit notes: "Google Calendar:" —> "View map:"
Have you isolated this by outputting an all hard-coded link in double brackets?
Okay, great, it was actually a small oversight by me, but I do love and appreciate the creative recommendation. Plain text links work now. THANK YOU!
I'm so close and I'll stop bothering you...!!! Lastly, for the HTML version I have a variable in my email script that needs to be a link. It needs to link to an image as well as to text. Best way to do that?
In the email script:
Neither of these will work for BOTH text and an image... Any possible workarounds?
After I get this to work, I'll look into polymorphic tokens for sure.
It needs to link to an image as well as to text. Best way to do that?
In the email script:
Neither of these will work for BOTH text and an image.
Not sure what you mean. Do you mean you need a plain-text link and also an HTML link whose inner content is an <IMG>? If you could explain the output goal (never mind how Velocity gets there, just let me know what output you're looking for on the text and HTML sides) that would be helpful.
Sorry, that was horrible wording. Let me rephrase. What I'm trying to accomplish is create a velocity email script that is a link that can wrap around text and/or an image.
For example, the email script token would be a Google Maps link that is linked to the words "view map" and an image of a map.
So when you proposed to explicitly compose a full anchor tag in the email script token, like so:
the script will only work depending on what I place inside the anchor tag. It can either be text OR an image but it can't be both.
So my intuition tells me to leave out the closing anchor tag in the script token, so it looks like this:
and then have the closing </a> in he HTML. Problem is Marketo will see a closing tag and no opening tag and remove the closing one before it processes the script. So that's not feasible.
So... question is... how can I get an email script to contain a link value that can work with text AND images?
*If this still doesn't make sense, I don't mind elaborating. Your help has been extremely appreciated.