How to track your HTML links in an Adobe Campaign delivery when they are generated from upstream data targetData?

πŸ”—πŸ”Žβ˜οΈ

Step 0: Prerequisites

  • Campaign with a Query, an Enrichment with customUrl field and an Email delivery:
    • With a static link <a href="https://blog...">
    • With a targetData link <a href="<%= targetData.customUrl %>">
    • β€œDisplay URLs” checked

ACC only recognizes the static link:

Let’s fix it!

Step 1/2: href must start with https://

  • Prefix <%= targetData with https://
  • Remove https:// (or http://) in the targetData.link with the regex .replace(/^https?:\/\//, '')

Step 2/2: Tracking formula for UTM codes

  • The tracking link formula doesn’t work with targetData:

  • This is because by default the formula has a condition on $(urlstring):

  • And the formula is executed BEFORE targetData is replaced by its content!
  • The condition regex must contain a OR targetData :
    <%@ include option='NmsTracking_ClickFormula' %>
    <%
    var pattern = /(blog\.floriancourgey\.com|targetData)/i;
    if( $(urlstring).match(pattern) ){
    %>
    &utm_source=newsletter&utm_medium=email&utm_campaign=<%= message.delivery.internalName %>
    <% } %>
    

  • Which results in a targetData link tracked with UTM via the delivery formula: