Expand my Community achievements bar.

obtener Variables UTM delivery

Avatar

Level 2

Good morning,
I am trying to retrieve these variables to add them as UTM parameters in a URL from a delivery but unfortunately when previewing they are always empty except the transaction ID.

I am using them like this inside the HTM Context.
<p>Message type: <%= delivery.messageType %></p>
<p>Operation ID: <%= delivery.operation_id %></p>
<p>Operation label: <%= delivery.operation.label %></p>
<p>Internal name of operation: <%= delivery.operation.internalName %></p>

The idea is to somehow fill in these variables.
(utm_medium ,utm_source ,utm_campaign,utm_content,utm_term)
to be able to concatenate them in my url, can you help me?

Thank you!

 

11 Replies

Avatar

Level 3

Hi @JESUSBA1 

 

You can add that info by customizing your ''NmsTracking_ClickFormula'' option:

OscarGo_0-1719914914159.pngOscarGo_1-1719914967490.png

 

Avatar

Level 2

Thank you! How can I rescue the channel, I still see it empty?

Thank you very much.

Avatar

Level 3

Hi @JESUSBA1 

You can take the Channel with "message.delivery.messageType"

Hope it helps

Avatar

Level 2

yes, this always returns 0.

this is my complete code to try to parameterize my URLs dynamically.
i have saved it in a customization block, but i don't know how to implement it so that it can be added in the html urls when i do the delivery, sorry but i don't know how to do it otherwise. thank you very much
<%
// Get the UTM fields from the current delivery.

var utmSource = (typeof variables !== 'undefined' && variables.utmSource) ? variables.utmSource : (delivery.source || "Source");
var utmMedium = (typeof variables !== 'undefined' && variables.utmMedium) ? variables.utmMedium : ("Email");
var utmCampaign = (typeof variables !== 'undefined' && variables.utmCampaign) ? variables.utmCampaign : (message.delivery.operation.label || "Campaign");
var utmContent = (typeof variables !== 'undefined' && variables.utmContent) ? variables.utmContent : (delivery.deliveryCode || "Content");
var utmTerm = (typeof variables !== 'undefined' && variables.utmTerm) ? variables.utmTerm : (delivery.operation_id || "Term");

 

// Construct the URL with UTM parameters
var finalUrl = "?utmSource=" + encodeURIComponent(utmSource) +
"&utmMedium=" + encodeURIComponent(utmMedium) +
"&utmCampaign=" + encodeURIComponent(utmCampaign) +
"&utmContent=" + encodeURIComponent(utmContent) +
"&utmTerm=" + encodeURIComponent(utmTerm);

<!-- HTML content for the block -->
%>

<%= finalUrl %>

In delivery I do this:

JESUSBA1_0-1719918265643.png

 

Avatar

Level 3

Hi @JESUSBA1 

You are getting a '0' because the Delivery Channel is defined as an Enumeration where values are numerical but labels string.

So if you have the OOO implementation 0 refers to "Email" channel.

I would suggest to check in your Deliveries data schema how you have defined the Channel enumeration to map the numerical value to the string representation if you want that.

 

 

 

Avatar

Level 2

thank you for your answer, when I use this code, the email never sends

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
</HEAD>
<BODY><a href="www.example.com<%@ include view='UMTOK' %>">link</a></BODY></HTML>

 

this can be used this way concatenated the include in the href?

Avatar

Level 3

Hi @JESUSBA1 

Could you please add logs of the delivery errors?

Avatar

Level 2

hello, it stays in this state.

JESUSBA1_0-1719989687994.png

these are the variables of the task

JESUSBA1_1-1719989748564.png

 

Avatar

Level 3

Hi @JESUSBA1 

To see the delivery error logs you can take them from the campaign workflow itself by:

  • Right-click on the delivery activity > Display logs

OscarGo_0-1719990635691.png

 

  • Click on the Journal icon while having selected the Delivery activity

OscarGo_1-1719990644600.png

 

 

Avatar

Level 2

That's where I'm looking at it, it doesn't give me any information beyond that.

Maybe it's giving an error to include it inside the href when concatenating it? this is my customization block.

 

JESUSBA1_0-1719992534692.png

 

Avatar

Level 2

Solved, I managed to make it work by creating a content block to retrieve the variables and using the variable directly in the html.

 

JESUSBA1_0-1719998727196.png