Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

Add parameter to every link in delivery from variables

Avatar

Level 2

Hi all,

I'm quite new to ACC, so I hope I'm not doing a mistake here which it to obvious...

 

We have a requirement to add a URL parameter to every link within an email delivery. The parameter is called "campaignId" and it's value should be set on each delivery and then appended to all links in the delivery (with the same value for all links).

So what I tried was the following:

  • Set the parameter value as variable "campaignId" in each campaign
  • Add the following typology rule:
    • Rule type: control
    • Phase: After targeting
    • Execution order: 50
    • Code:

var campaignId = delivery.variables._var[0].stringValue;

if(campaignId !== 'undefined' && campaignId.length > 0){
   var deliveryUrlsLength = delivery.content.html.urlConfig.url.length;

   // Loop through all URLs
   for (var i = 0; i < deliveryUrlsLength; i++){
      var urlSource = delivery.content.html.urlConfig.url[i].source;
      if(urlSource !== 'undefined' && urlSource.length > 0){
         var appendChar = "?";
         // Check if the URL Source already contains at least one parameter
         if(urlSource.indexOf("?") > 0){
            appendChar = "&";
         }
         //Add the campaignId to the urlSource
         delivery.content.html.urlConfig.url[i].source = urlSource + appendChar + "campaignId=" + campaignId;
         delivery.content.html.urlConfig.url[i].withParams = true;
         delivery.content.html.urlConfig.url[i].modified = true;
         logInfo("Appended campaignId to link: " + delivery.content.html.urlConfig.url[i].source);
      }
   }
}

return true;

 

Analyze runs fine and the logInfo messages look fine as well. When sending the mails, links are rewritten for targeting, but when clicking the links, the campaignId parameter is not appended.

Any hints on what I'm doing wrong? Is this the correct approach at all?

 

Thanks for your input!

 

BR

Sebastian

 

1 Accepted Solution

Avatar

Correct answer by
Level 3

Hi @Sebastian_Rockw 

 

David's option might be cleaner, but this is how we did it : We created a 'web analytics' external account and added our custom url parameters in the tracked URL calculation as shown below. We have also integrated our Analytics account to Campaign with the option below that, but I think you can just skip that if you don't need it?

 

xavierv6303633_0-1606762234538.png

You will then be able to select this external account in the 'web analytics' tab of your deliveries. Every delivery with this account linked will change all tracked URLs as defined in that external account. 

xavierv6303633_1-1606762667032.png

Again, you can ignore the fields below the account selection. I would also reccommend adding a field in the campaign's input form to add your campaignId instead of using variables, which will make it easier to fetch in the script.

 

Kr,

Xavier

View solution in original post

4 Replies

Avatar

Community Advisor

Hi Sebastian,

 

Add a logInfo(campaignId) to see if your variable is set up correctly.

Another way ( i think easier to achieve this) is to update NmsTracking_ClickFormula option.

 

Thanks,

David



David Kangni

Avatar

Level 2
Thank you David. Modifing the tracking click formula did the trick!

Avatar

Correct answer by
Level 3

Hi @Sebastian_Rockw 

 

David's option might be cleaner, but this is how we did it : We created a 'web analytics' external account and added our custom url parameters in the tracked URL calculation as shown below. We have also integrated our Analytics account to Campaign with the option below that, but I think you can just skip that if you don't need it?

 

xavierv6303633_0-1606762234538.png

You will then be able to select this external account in the 'web analytics' tab of your deliveries. Every delivery with this account linked will change all tracked URLs as defined in that external account. 

xavierv6303633_1-1606762667032.png

Again, you can ignore the fields below the account selection. I would also reccommend adding a field in the campaign's input form to add your campaignId instead of using variables, which will make it easier to fetch in the script.

 

Kr,

Xavier

Avatar

Level 2
Thank you Xavier. Followed your detailed description and not it works fine