Expand my Community achievements bar.

SOLVED

Web analytics Account configuration

Avatar

Level 3

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.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi Ram,

There are 2 topics on your context

 

  1. The URL doesn't know the context is it HREF in: Button or Link, what you would do if to add a label for all the tracked link via the _label element and you could introduce a naming convention (btn, lnk, img). The label is what is seen in the URL & Clickstream reports and is Adobe internal only.
  2. The 2nd part is the trickiest one as in the TrackingFormula associated to the Web Analytics external account, you would have to loop through the list of tracked URL, matching to the one current prepared, look at whether it contains one of the naming convention and set the content_tum accordingly. The code would look like as below

<%@ 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

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

Hi Ram,

There are 2 topics on your context

 

  1. The URL doesn't know the context is it HREF in: Button or Link, what you would do if to add a label for all the tracked link via the _label element and you could introduce a naming convention (btn, lnk, img). The label is what is seen in the URL & Clickstream reports and is Adobe internal only.
  2. The 2nd part is the trickiest one as in the TrackingFormula associated to the Web Analytics external account, you would have to loop through the list of tracked URL, matching to the one current prepared, look at whether it contains one of the naming convention and set the content_tum accordingly. The code would look like as below

<%@ 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