How to Track dynamic content click through sent via Content builder

 In order to track the clickthrough’s in the dynamic content block, we need to use RedirectTo Function in the AmpScript

RedirectTo

 Overview

Allows a client to specify the target of a link originates from a complete URL stored in an attribute, data extension field, or variable. Only use this function within the href attribute of a tag. In text emails, include the prefix HTTP:// and ensure you use no spaces within the parentheses. In order to retain tracking information for clicked links, you must include the anchor tags () within the email itself and not the link retrieved via AMPscript. This function only provides tracking information for clickable links within an email message. You cannot retrieve tracking information when using this function with URLs stored in a variable or used as part of a query string parameter.

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/redirectto.html

Below code retrieves Contact owner information dynamically and populate in the email

%%[
var @ContactTable, @contactRow, @ownerTable, @ownerRow, @Id2, @contactId
var @contactownername, @contactownerTitle, @contactownerEmail, @contactownerPhone, @contactownerFullPhotoUrl, @linkEmail, @linkphone
Set @Contacttable = RetrieveSalesforceObjects("Contact", "Id, FirstName, LastName, Email, OwnerID", "Id", "=", _subscriberKey)
Set @contactId = _subscriberKey
Set @contactRow = Row(@ContactTable,1)
Set @Id2 = FIELD(@contactRow,"OwnerID")
Set @ownerTable = RetrieveSalesforceObjects("User", "Name, Title, Phone, Email, FullPhotoUrl", "Id", "=", @Id2)
Set @ownerRow = ROW(@ownerTable,1)
Set @contactownername = FIELD(@ownerRow, "Name")
Set @contactownerTitle = FIELD(@ownerRow, "Title")
Set @contactownerEmail = FIELD(@ownerRow, "Email")
Set @LinkEmail = "Mailto:%%=v(@contactownerEmail)=%%"
Set @contactownerPhone = FIELD(@ownerRow, "Phone")
Set @Linkphone = "tel:%%=v(@contactownerPhone)=%%"
Set @contactownerFullPhotoUrl = FIELD(@ownerRow, "FullPhotoUrl")
]%%
%%[If Not Empty(@Id2) Then]%%
<table width="278" align="left" class="deviceWidth" style="width: 278px; background-color: #ffffff;" bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="deviceWidth" style="padding-top: 10px; padding-bottom: 20px;">
<table width="84" align="left" style="width: 84px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding-right: 8px;">
<table align="left" style="width: 84px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" style="padding: 0px; border: 2px solid #009fdf; width: 84px;">
<img width="80" style="display: block;" alt=%%=v(@contactownername)=%% src = %%=v(@contactownerFullPhotoUrl)=%% border="0" />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table align="left" style="width: 180px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding-top: 0px; padding-right: 8px;">
<p style="margin: 0px; padding: 0px; color: #373737; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold;">
%%=v(@contactownername)=%% , <span style="font-weight: normal;">%%=v(@contactownertitle)=%%</span>
</p>
</td>
</tr>
<tr>
<td style="padding-top: 3px; padding-right: 8px;">
<p style="margin: 0px; padding: 0px; color: #373737; font-family: Arial, Helvetica, sans-serif; font-size: 12px;">
%%=v(@contactownerTitle)=%%
</p>
</td>
</tr>
<tr>
<td style="padding-top: 5px; padding-right: 8px;">
<p style="margin: 0px; padding: 0px; color: #009fdf; font-family: Arial, Helvetica, sans-serif; font-size: 12px;">
<a alias="%%=v(@contactownerPhone)=%%" href="%%=Redirectto(@Linkphone)=%%" style="color: #009fdf; text-decoration: none;">%%=v(@contactownerPhone)=%%</a>
</p>
</td>
</tr>
<tr>
<td style="padding-top: 5px; padding-right: 8px;">
<p style="margin: 0px; padding: 0px; color: #009fdf; font-family: Arial, Helvetica, sans-serif; font-size: 12px;">
<a alias="%%=v(@contactownerEmail)=%%" href="%%=Redirectto(@LinkEmail)=%%" style="color: #009fdf; text-decoration: none;">Email %%=v(@contactownername)=%% </a>
</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
%%[endif]%%

Add the above code in the content and drag the content block into the email that you want to send.

Below is the preview of how dynamic content block looks like

now you can track the click-through of Email and phone in tracking in link view tab

Leave a Reply