Where to add Sourcetag in Email Delivery when sending targeted e-mails through Adobe Campaign classic | Adobe Higher Education
Skip to main content
Level 4
February 2, 2025
Risolto

Where to add Sourcetag in Email Delivery when sending targeted e-mails through Adobe Campaign classic

  • February 2, 2025
  • 2 risposte
  • 2308 visualizzazioni

Hi team,

I have a requirement where we have to add sourcetags in Email Deliverywhen sending targeted e-mails through Adobe Campaign Classic

 

please help me to understand where we can add sourcetags in Email Deliverywhen sending targeted e-mails through Adobe Campaign Classic

 

Please let me know wheere and how  to add it  to all the links to the website in order to Analytics to track it 

Migliore risposta di ccg1706

Hello @ccg1706 

Thanks for your reply always ... .however I tried the code you mentioned

but still getting the same error

please help me with correct code please

 


Hi @dishasharma,

// Define the source tag var sourceTag = "E00040S3000D99908"; // Ensure the email content is accessible if (message && message.content && message.content.html && message.content.html.source) { var htmlContent = message.content.html.source; // Get the email HTML content // Convert email HTML to lowercase to avoid case sensitivity issues var modifiedContent = htmlContent.replace(/href="([^"]*?)"/gi, function(match, url) { if (url.indexOf("source=") === -1) { // Check if 'source=' already exists var separator = url.indexOf("?") > -1 ? "&" : "?"; return 'href="' + url + separator + "source=" + sourceTag + '"'; } return match; // Return unchanged if 'source=' is already present }); // Log modified content for debugging logInfo("Updated Email HTML: " + modifiedContent.substring(0, 500)); // Log first 500 characters to avoid truncation // Update the email content with the modified version message.content.html.source = modifiedContent; }

Try with these, additionally run it in a workflow before using it in a typology rule. If again fails you will have to open  a ticket to support sharing the error and your typology rule details.

 

Regards, 

Celia

 

 

 

2 risposte

ccg1706
Community Advisor
Community Advisor
February 2, 2025

Hi @shruti1,

 

There are different ways to add source tags:

 

-You can add them manually inside your html content within the delivery you are sending. Example:<a href=" yourlink?utm_source=AdobeCampaign&utm_medium=email&utm_campaign=SpringSale">

- As manually is a waste of time, you can enable tracking on all URLS inside the mail go to properties tab.

<--Image taken for Adobe Documentation>
-You can also create a typology rule where you add Java Script to add UTM parameters for every link. A possible JS could be this:

var content = delivery.content.html.source; //grabs the content of the HTML and stores it in the variable content content = content.replace(/href="(https:\/\/www\.example\.com[^"]*)"/g, 'href="$1&utm_source=AdobeCampaign&utm_medium=email"');//Replace example with the link you want to put.

 

Test which method is better for you but I'll recommend the second one.

Additionally I leave you a useful doc link:Tracking messages 

Kind regards, 

Celia

Shruti1Autore
Level 4
February 4, 2025

hi @celia thanks for your reply

but i need to create typology rule

that loops over all the url in delivery and add the source tag

Source tag=

E00040S3000D99908

 

could you please suggest correct typology rule fort his

ccg1706
Community Advisor
Community Advisor
February 6, 2025

Hi @shruti1,

 

Under Adminisitration-Campaign Management-Typologies you can create a typology rule applying the following JavaScript

 

// Define the source tag var sourceTag = "E00040S3000D99908"; // Function to check if a URL already contains the source tag function appendSourceTag(url) { var separator = url.includes("?") ? "&" : "?"; // Determine if ? or & is needed return url + separator + "source=" + sourceTag; } // Loop through all URLs in the delivery var delivery = delivery.content.html.source; // Get the HTML content var modifiedContent = delivery.replace(/href="([^"]+)"/g, function(match, url) { // Append source tag if not already present if (!url.includes("source=")) { return 'href="' + appendSourceTag(url) + '"'; } return match; // If the source already exists, keep it as it is }); // Update the content of the delivery delivery.content.html.source = modifiedContent;

 

Let me know if it helps.

 

Regards,

Celia

Shruti1Autore
Level 4
February 4, 2025

 

Hi team,

I have a requirement where we have to add sourcetags in Email Deliverywhen sending targeted e-mails through Adobe Campaign Classic in click formula 

NmsTracking_ClickFormula

please help me to understand where we can add sourcetags in NmsTracking_ClickFormula under Platform->options

Alternatively, can we create typology rule

that loops over all the URL in delivery and add the as the source tag

-->PLEASE GUIDE ME ON THIS PART

 

Please let me know where and how  to add the source tag to all the urls in email delivery in order to Analytics to track it 

ccg1706
Community Advisor
Community Advisor
February 5, 2025

Hi @shruti1,

 

It would be more practical, to create a typology rule, cause it is more flexible and allows you to process all URLs dynamically within the email content before sending or you can modify the NmsTracking_Clickormula).

 

Applying JavaScript you can do it, defining the variables and a for to loop trough each link and append the sourcetag.

 

If you need more help, just let me know.

 

Regards,

Celia

Level 4
February 5, 2025

Hello @ccg1706

 

I also need to work on same requirement:

 

I need, to create a typology rule, and which allows you to process all URLs dynamically within the email content before sending

Applying JavaScript you can do it, defining the variables and a for to loop trough each link and append the sourcetag.

my source tag is: For FB: SOURCETAG=C0030P3000A99P0000F0000MCD0

can u help me with the code for typology rule for this please

 

also second method:

where we can modify the NmsTracking_Clickormula, can u give me the code for this NmsTracking_Clickormula-modified with addition of sourcetag