Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

SanfordWhiteman
Level 10 - Community Moderator

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

Another good reason to use the technique, then.

(Which btw you can read about here: https://nation.marketo.com/community/product_and_support/blog/2017/04/11/multiple-tracked-links-in-v...)

Chris_Politzki
Level 2

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

Still struggling to get a working example...might you be able to point us in the right direction? Thanks.

Tony_Mayse
Level 3

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

The link should be output using the first form from the examples at the bottom of https://developers.marketo.com/email-scripting/

#set($url = "www.example.com/${object.id}")
<a href="http://${url}">Link Text</a>

It''s necessary for the anchor tag be included as a literal up to the //

Without that technique, the link will not be tracked. That's not a Velocity constraint, it's implementation-specific to Marketo's tracked link functionality.

Chris_Politzki
Level 2

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

Thanks. I will have to check with our DB Admin to see if they can strip the https:// off of the Custom Object field, but that does work, just tested it.  

SanfordWhiteman
Level 10 - Community Moderator

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

Thought you said you had tested it above?

Anyway, you also need to change the VML namespace's friendly name like I mentioned above::

#set( $custom_query_string = $campaign_days_map.get($campaignDays) )
#set( $url_no_host = $TriggerObject.URL + $custom_query_string )
#set( $anchorLink = '<a href="https://${url_no_host}" alias="Renew Now" class="mktoText primary-font button" style="background-color: #f96b07; border-radius: 3px; color: #ffffff; display: inline-block; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; line-height: 46px; text-align: center; text-decoration: none; text-size-adjust: none; width: 100% !important;"><span style="color: #ffffff; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; text-transform: uppercase;">Renew Now</span></a>' )
<tbody>
<tr>
<td class="primary-font button" style="-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;width: 250px; height: 46px; text-decoration: none;font-weight: 700; font-family: 'Arial', sans-serif; color: #ffffff;font-size: 16px;text-align: center;line-height:13px;" bgcolor="#ff6a13" height="46">
<div class="mktoText">
<!--[if mso]>
<a:roundrect xmlns:a="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://${url_no_host}" style="height:65px;v-text-anchor:middle;width:175px;" arcsize="6%" stroke="f" fillcolor="#f96b07">
<w:anchorlock/>
<center>
<![endif]-->
${anchorLink}
<!--[if mso]>
</center>
</a:roundrect>
<![endif]-->
</div>
</td>
</tr>
</tbody>
Chris_Politzki
Level 2

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

I must have had a syntax error in that test, I'm assuming...it does seem to be working now. Let me do a few more tests to confirm and also talk with our DB Admin to confirm we can edit that field for the URL before marking this thread as being completed. Thanks.

Tony_Mayse
Level 3

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

The code above doesn't generate a tracked link because ${anchorLink} contains the entire tag. Marketo's Velocity scripting will only output a tracked link when the tag itself is literal rather than stored in a variable.

Moving the value assigned to ${anchorLink} on line 3 to line 13 is what's need. Line 13 should be:

<a href="https://${url_no_host}" alias="Renew Now" class="mktoText primary-font button" style="background-color: #f96b07; border-radius: 3px; color: #ffffff; display: inline-block; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; line-height: 46px; text-align: center; text-decoration: none; text-size-adjust: none; width: 100% !important;"><span style="color: #ffffff; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; text-transform: uppercase;">Renew Now</span></a>

and line 3 should be removed.

SanfordWhiteman
Level 10 - Community Moderator

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

That's tested code, Tony.

SanfordWhiteman
Level 10 - Community Moderator

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

The code above doesn't generate a tracked link because ${anchorLink} contains the entire tag. Marketo's Velocity scripting will only output a tracked link when the tag itself is literal rather than stored in a variable.

You'll find that the rules are more complex than this.

Chris_Politzki
Level 2

Re: Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value

Here's what I came up with that works currently...pending we can manipulate the URL value.

Set URL value from Custom Object without https://, so now just www.webroot.com/us/en/cart (still have to confirm with others to see if this can be done):

#set($URL = $TriggerObject.URL)

Still setting the Custom Query Strings the same way, but then changed the way full_url is being built to this:

#set($full_url = $URL + $custom_query_string)

Then setting the anchorLink to be used in email token content:

#set($anchorLink = "${full_url}")

In the content for the button:

<tbody> 
<tr>
<td class="primary-font button" style="-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;width: 250px; height: 46px; text-decoration: none;font-weight: 700; font-family: 'Arial', sans-serif; color: #ffffff;font-size: 16px;text-align: center;line-height:13px;" bgcolor="#ff6a13" height="46">
<div class="mktoText">
<!--[if mso]>
<a:roundrect xmlns:a="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://${anchorLink}" style="height:65px;v-text-anchor:middle;width:175px;" arcsize="6%" stroke="f" fillcolor="#f96b07">
<w:anchorlock/>
<center>
<![endif]-->

<a href="https://${anchorLink}" target="_blank" style="background-color: #f96b07; border-radius: 3px; color: #ffffff; display: inline-block; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; line-height: 46px; text-align: center; text-decoration: none; text-size-adjust: none; width: 100% !important;">
<span style="color: #ffffff; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; text-transform: uppercase;">
Renew Now
</span>
</a>
<!--[if mso]>
</center>
</v:roundrect>
<![endif]-->

</div>
</td>
</tr>
</tbody>

In the content for the banner:

<a href="https://${anchorLink}" target="_blank">
<img src="https://mypage.webroot.com/rs/557-FSI-195/images/PERPETUAL-RENEWAL-EMAIL1.png" alt="90 Days to Renew" style="-ms-interpolation-mode: bicubic; outline: none; border-right-width: 0; border-bottom-width: 0; border-left-width: 0; text-decoration: none; border-top-width: 0; display: block; max-width: 100%; line-height: 100%; height: auto; width: 700px;" width="700">
</a>