Getting Marketo to track a link created in a Velocity Token pulling a Custom Object value | Community
Skip to main content
Chris_Politzki
Level 2
October 17, 2019
Question

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

  • October 17, 2019
  • 2 replies
  • 6489 views

Having difficulties in getting this trackable by Marketo. Activity type should be 'Click Email' and not 'Visit Webpage'.

In Velocity Tokens:

Setting Custom Query Strings:

#set($campaign_days_map = {
90 : "?rc=5346&ac=2019&utm_medium=email&utm_source=marketo&utm_campaign=perpetual-wwall-email-renewal-90days",
60 : "?rc=5346&ac=2020&utm_medium=email&utm_source=marketo&utm_campaign=perpetual-wwall-email-renewal-60days",
30 : "?rc=5346&ac=2021&utm_medium=email&utm_source=marketo&utm_campaign=perpetual-wwall-email-renewal-30days",
7 : "?rc=5346&ac=2022&utm_medium=email&utm_source=marketo&utm_campaign=perpetual-wwall-email-renewal-7days",
0 : "?rc=5346&ac=2023&utm_medium=email&utm_source=marketo&utm_campaign=perpetual-wwall-email-renewal-dayzero",
-7 : "?rc=5346&ac=2024&utm_medium=email&utm_source=marketo&utm_campaign=perpetual-wwall-email-renewal-7dayspost",
-14 :"?rc=5346&ac=2025&utm_medium=email&utm_source=marketo&utm_campaign=perpetual-wwall-email-renewal-14dayspost"
})

Grabbing the Custom Object URL value, which is usually https://www.webroot.com/us/en/cart (also have tried without the https://):

#set($custom_query_string = $campaign_days_map.get($campaignDays))
#set($full_url = $TriggerObject.URL + $custom_query_string)

Setting the constructed URL with Custom Query String for the A Tag href value:

#set($anchorLink = '<a href="${full_url}" 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>')

Reference to the set URL + Query String Value in Content created by a separate Velocity Token:

<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]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="${full_url}" style="height:65px;v-text-anchor:middle;width:175px;" arcsize="6%" stroke="f" fillcolor="#f96b07">
<w:anchorlock/>
<center>
<![endif]-->

${anchorLink}
<!--[if mso]>
</center>
</v:roundrect>
<![endif]-->

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

This creates the Activity Type of 'Visit Webpage', but we are hoping that the link gets wrapped in the Marketo tracking and creates an Activity Type of 'Click Email'.

Any help or assistance would greatly be appreciated, thanks in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

SanfordWhiteman
Level 10
October 17, 2019

Before dipping further, are you testing only in Outlook (I am asking because of the VML) or have you tested other clients?

Chris_Politzki
Level 2
October 17, 2019

At the moment, only Outlook, but I can run it through GMail here shortly, thanks.

Justin_Eichelb1
Level 2
October 17, 2019

I think Chris tested a Gmail a couple of weeks ago as he thought it might be an outlook issue. And if remember correctly, Gmail failed also.  But he's made code changes since then. So, his gmail test might have different results now.

Tony_Mayse
Level 2
October 18, 2019

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
October 18, 2019

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
October 18, 2019

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>