0

URL conacatenation is not working in the content area generated through SSJS script .The scenario is we are generating a content through SSJS and its stored in the content area and its then pulled into the email.But the URL concatenation is not working during the email send.

  var url ="www.example.com/test/search?Author=";    
  var name="fname+test";
  var link=url+name;
  var finallink="<a href="+link+"> Author </a>";

  Output shown in Email preview is : www.example.com/test/search?Author=fname+test
  Output shown after email send on mouse hover  :click.info.test.org/?qs=1335454=fname+test
  Output after link redirection :https://www.example.com/test/search?Author&utm_medium=test&utm_source=test

From the above output you can see that after link redirection everything after "Author" has been removed.

I have tried Platform.Function.UrlEncode("http://www.example.com?value=123 123"); but this doesn't help.

what should i do for URL concatenation in SSJS? I have included my sample script and this is how i have concatenated the URL,

<script runat=server>
  Platform.Load("Core","1");
  var url="https://example.com/search-results?f_Authors=";
  var url1="test+test"; //TO BE OBTAINED DYNAMICALLY   
  var finalurl=url+url1;
  var Author1="The Authour link is ---<a href="+finalurl+">Author</a>";
  var Author=Author1+"<br>";
  Write("The URL is ::"+Author);
  var obj = ContentAreaObj.Init('exampleArea13'); 
  var status = obj.Update({"Content" : Author });
</script>
  • Does this need to be in SSJS? I think using AMPScript would be better, especially for efficiency and performance. – Gortonington Feb 1 '18 at 14:06
  • Can you also show how you are outputting this? – Gortonington Feb 1 '18 at 14:08
  • I do agree with that, but I am getting this content from API where the API response takes too long and eventually failing at times so i cannot directly use that in Email.So i am using Script activity to get the data and the JSON returned is huge so SSJS is simpler to use in this case.And then storing in content area. – Manoj Chandran Feb 1 '18 at 14:09
  • Updated the script in the original question – Manoj Chandran Feb 1 '18 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.