Email Template Variable Breaking Link Tracking

nhabischWings
Level 5

Email Template Variable Breaking Link Tracking

Hello all, here with a (probably) basic question. Our email template(s) are setup using variables for better styling control, but in a certain case I think it may be breaking the tracking of URLs pulled from Custom Fields.
Here's code for reference:

 <!--Button Only Section Variables-->
 <meta class="mktoList" id="buttonLocation" mktoName="Button Location" values="center,left,right">
 <meta class="mktoList" id="buttoncolor" mktoName="Background Color" values="#0072CE,#003087">
 <meta class="mktoList" id="buttonbordercolor" mktoName="Border Color" values="#0072CE,#003087">
 <meta class="mktoList" id="buttontextcolor" mktoName="Text Color" values="#ffffff" />
 <meta class="mktoString" id="buttonLink" mktoName="Button Link" default="">
 <meta class="mktoString" id="buttonText" mktoName="Button Text" default="Click Here">


<!-- ====================Button Only In-Template Code=========================== -->
<tr id="buttonOnly" mktoName="Button" class="mktoModule"><td>
              <!--[if mso | IE]>
            <tr>
              <td class="" width="600px">
      <table
         align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600">
        <tr>
          <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
      <![endif]-->
              <div style="margin:0px auto;max-width:600px;">
                <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
                  <tbody>
                    <tr>
                      <td style="direction:ltr;font-size:0px;padding:5px 20px;text-align:center;">
                        <!--[if mso | IE]>
                  <table role="presentation" border="0" cellpadding="0" cellspacing="0">

        <tr>
            <td class="" style="vertical-align:top;width:560px;">
          <![endif]-->
                        <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
                          <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
                            <tr>
                              <td align="${buttonLocation}" style="font-size:0px;padding:10px 25px;word-break:break-word;">
                                <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;">
                                  <tr>
                                    <td align="center" bgcolor="${buttoncolor}" role="presentation" style="border:2px solid ${buttonbordercolor};border-radius:15px 0;cursor:auto;mso-padding-alt:17px 30px;background:${buttoncolor};" valign="middle">
                                      <a href="https://${buttonLink}" style="display:inline-block;background:${buttoncolor};color:${buttontextcolor};font-family: 'Montserrat', 'sans-serif';font-size:16px;font-weight:bold;line-height:120%;margin:0;text-decoration:none;text-transform:none;padding:12px 20px;mso-padding-alt:0px;border-radius:15px 0;" target="_blank">${buttonText} <img style="vertical-align:middle;" src="http://pages.WingsFinancial.com/rs/324-LYF-114/images/icon-btn-right-arrow.png" /> </a>
                                    </td>
                                  </tr>
                                </table>
                              </td>
                            </tr>
                          </table>
                        </div><!--[if mso | IE]>
            </td>
        </tr>
                  </table>
                <![endif]-->
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div><!--[if mso | IE]>
          </td>
        </tr>
      </table>
              </td>
            </tr>
          <![endif]-->
        </td>  </tr>
<!-- ====================End Button Only=========================== -->

So you'll notice the HREF tag is href="https://${buttonLink}" and if I used a custom field URL with the correct usage per (Creating trackable links even when a token include... - Marketing Nation (marketo.com)) it should appear like this href="https://{{lead.Consumer Loans - Survey Link for New Auto Loan}}" and should be trackable?

Am I missing something silly?

1 REPLY 1
Crystal_Pacheco
Level 4

Re: Email Template Variable Breaking Link Tracking

Hi @nhabischWings , quick question is your token {{lead.Consumer Loans - Survey Link for New Auto Loan}} a velocity script token? Did you implement the fix as outlined in the post you shared? That fix has worked for me in the past.
If you do implement the fix from the post, you will need to restructure your button's html, because the <a href=""></a> will be contained within the velocity script token.

Velocity script example:

#set( $urlField = $lead.ConsumerLoans-SurveyLinkforNewAutoLoan )
#set( $urlNoProto = $urlField.replaceAll("(?i)^https?://","") )
#if( $urlField.matches("(?i)^http://") )
<a href="http://${urlNoProto}" style="display:inline-block;background:#000000;color:#FFFFFF;font-family: 'Montserrat', 'sans-serif';font-size:16px;font-weight:bold;line-height:120%;margin:0;text-decoration:none;text-transform:none;padding:12px 20px;mso-padding-alt:0px;border-radius:15px 0;" target="_blank">CTA Button Text<img style="vertical-align:middle;" src="http://pages.WingsFinancial.com/rs/324-LYF-114/images/icon-btn-right-arrow.png"></a>
#else
<a href="https://${urlNoProto}" style="display:inline-block;background:#000000;color:#FFFFFF;font-family: 'Montserrat', 'sans-serif';font-size:16px;font-weight:bold;line-height:120%;margin:0;text-decoration:none;text-transform:none;padding:12px 20px;mso-padding-alt:0px;border-radius:15px 0;" target="_blank">CTA Button Text<img style="vertical-align:middle;" src="http://pages.WingsFinancial.com/rs/324-LYF-114/images/icon-btn-right-arrow.png"></a>
#end 

 

 

HTML to replace the button link with the velocity script token

<td align="center" bgcolor="${buttoncolor}" role="presentation" style="border:2px solid ${buttonbordercolor};border-radius:15px 0;cursor:auto;mso-padding-alt:17px 30px;background:${buttoncolor};" valign="middle">
{{my.VelocityButton}}
</td>