Hi,
We are using web analytics account to add UTM tags. In Email delivery we are using newsletter defined in the publication template. In template there are multiple buttons and URL are configured. Our requirement is too add utm tags with custom attribute. I have added below code in the Web analytics external Account. When I click the link or button present in the email I can see the UTM tags in the URL.
<%@ include option='NmsTracking_ClickFormula' %><% // Parameters expected by Adobe Analytics Data Connector
var pattern = new RegExp("(www)", 'i')
var mtype= message.delivery.messageType;
if( $(urlstring).match(pattern) && delivery.FCP == false && mtype==0)
{
%>&utm_source=abc&utm_medium=email&utm_campaign=<%= message.delivery.customAttribute %><% }
else
{%>
&utm_source=abc&utm_medium=sms&utm_campaign=<%= message.delivery.customAttribute %>
<% }%>
The new requirement is, if the customer clicks button in the email then UTM content should display as button. If Link is clicked then UTM content should be displayed as link in the URL.
Example for
button: www.google.se?utm_source=abc&utm_medium=email&utm_campaign=Abc&utm_content=button
Link: www.google.se?utm_source=abc&utm_medium=email&utm_campaign=Abc&utm_content=link
Could any one please guide me how to achieve this.
Thanks in advance.
Ram.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Ram,
There are 2 topics on your context
<%@ include option='NmsTracking_ClickFormula' %><% var pattern = new RegExp("(^(http|https)://(.*))", 'i'); if ($(urlstring).match(pattern)) { var contentType; for (var x=0; x<delivery.content.html.urlConfig.url.length; x++) { if (delivery.content.html.urlConfig.url[x].tagId == "$(urlId)" && delivery.content.html.urlConfig.url[x].label > "") { contentType =delivery.content.html.urlConfig.url[x].label; }} contentType = contentType.replace(/\s/g,"_"); %>&utm_content=<%= escapeUrl(contentType) %>&cid=<%= message.delivery.internalName %>&bid=<%= message.id.toString().toLowerCase() %><% } %>
The above code loops through the list to tracked URL and will put the delivery label in the utm_content parameter, you would have to rework it that the label of the URL is tested to include btn, img or lnk as part of it to set the utm_content accordingly.
Try the above to ensure it compiles and works and then adapt to your need.
All I can think of and I hope it helps.
Thanks,
Denis
Hi Ram,
There are 2 topics on your context
<%@ include option='NmsTracking_ClickFormula' %><% var pattern = new RegExp("(^(http|https)://(.*))", 'i'); if ($(urlstring).match(pattern)) { var contentType; for (var x=0; x<delivery.content.html.urlConfig.url.length; x++) { if (delivery.content.html.urlConfig.url[x].tagId == "$(urlId)" && delivery.content.html.urlConfig.url[x].label > "") { contentType =delivery.content.html.urlConfig.url[x].label; }} contentType = contentType.replace(/\s/g,"_"); %>&utm_content=<%= escapeUrl(contentType) %>&cid=<%= message.delivery.internalName %>&bid=<%= message.id.toString().toLowerCase() %><% } %>
The above code loops through the list to tracked URL and will put the delivery label in the utm_content parameter, you would have to rework it that the label of the URL is tested to include btn, img or lnk as part of it to set the utm_content accordingly.
Try the above to ensure it compiles and works and then adapt to your need.
All I can think of and I hope it helps.
Thanks,
Denis
Views
Likes
Replies