I'm trying to add specific project info into URL's in an AMPscript driven database system. In doing so I've tried using the URLEncode() function as described here. Trouble is that it doesn't appear to be encoding the spaces as %20 as I'd expect. In fact, it's simply leaving the spaces in the URL as spaces. This doesn't seem to interfere with the Anchor tags but I'm concerned in some ways it could. I've tried two methods. One is to add the product name to the URL which is using a GUID code to actually develop the landing page content. The url might be pages.info.bentley.com/database/?guid=jhgd-yuio-etc.&name=should have no spaces -

I've tried to only urlencode the @NAME variable as

SET @EncodeName = URLEncode(@Name)


and I've also tried to URLEncode the whole link within the landing page. as: %%=URLEncode(http://pages.info.bentley.com/product/?GUID=%%=v(@GUID)=%%&name=%%=v(@Name)=%%)=%%. The second variation (Encode the whole address) is delivering an error message indicating I have no closing parenthesis (which seems untrue) and the top one (encoding just the name parameter) draws the name but spaces remain as spaces. I've tried adding the optional parameter of a 0, or a 1 to force it to react but same results.

1 Answer 1


Try this way

%%=URLEncode(concat('http://pages.info.bentley.com/product/?GUID=', @GUID, '&name=', @Name)) =%%

The extra percent signs and v() aren't required.

  • Thanks Kelly, I'm really working to be more mindful of when the v is or is not required along with other things that sometimes are and other times are not required. Maybe I need to review the AMPscript lessons on ET's site. That said I implemented the code and somehow the product name still appears to have spaces within. But I learned a little about concat so no loss!
    – Jonny Shaw
    Feb 25, 2014 at 21:54
  • ,I'll try it out and see if I can get it when I can look in my account Feb 25, 2014 at 22:19
  • Peculiar thing happened here! I replaced my code with your suggestion, went into FF to test and saw "spaces" remaining (SET @thought = ("Aaaargh!") so I was pasting it elsewhere to share here and saw my %20's! I realized then that FF was replacing the %20's in the URL to make them appear as spaces (it does this?) which makes me wonder if the encoding was working in the first place but simply not visible (to the naked eye) I haven't tested that but it is working properly now. I'll need to test it soon and bring it back here.
    – Jonny Shaw
    Feb 26, 2014 at 13:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.