Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Add parameter to every link in delivery from variables

Avatar

Avatar
Validate 1
Level 1
Sebastian_Rockw
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
Sebastian_Rockw
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
Sebastian_Rockw
Level 1

30-11-2020

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

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 2
xavierv6303633
Level 2

Likes

4 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Contributor
Shape 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
xavierv6303633
Level 2

Likes

4 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Contributor
Shape 1
Boost 3
Boost 1
View profile
xavierv6303633
Level 2

30-11-2020

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

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
MVP
DavidKangni
MVP

Likes

248 likes

Total Posts

359 posts

Correct Reply

142 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Validate 1
MVP
DavidKangni
MVP

Likes

248 likes

Total Posts

359 posts

Correct Reply

142 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
DavidKangni
MVP

30-11-2020

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