I have to pass Email in URL parameter of Unsubscribe link from Email.

Since PII should not appear in URL so i want to encode it. I have written below ampscript:

var @clientkey, @clientkeyencoded, @URLunsubscribe,@enc64
SET @clientkey = SubscriberKey
SET @clientkeyencoded = URLencode(@clientkey,1,1)
SET @URLunsubscribe = Concat("http://example.com/unsubscribe/?sk=",@clientkeyencoded)

and Passing in Email like:


But Issue: once i click on link it's not showing the encoded parameter and Error page is showing

"Bad Request - Invalid URL" "HTTP Error 400. The request URL is invalid."

  • 5
    URL encoding is not encryption, so I would discourage using that function if your goal is to obfuscate PII as it can be easily decoded. Is your unsubscribe page also hosted within SFMC (e.g., CloudPages) or is it external? If the former, you can encrypt query strings using the CloudPagesURL function. – Mark G Jul 16 '19 at 15:40

Are you testing this with a Data Extension and do you have a field in it named 'SubscriberKey'? If not, you will need to use '_SubscriberKey' to pull in the system defined SubscriberKey value, like noted here.

Additionally, it doesn't appear that for your use case you should be using URLEncode(), and should be using Base64Encode().

Something similar to the following:

var @clientkey, @clientkeyencoded, @URLunsubscribe,@enc64
SET @clientkey = _SubscriberKey
SET @clientkeyencoded = Base64Encode(@clientkey)
SET @URLunsubscribe = Concat("http://example.com/unsubscribe/?sk=",@clientkeyencoded)

|improve this answer|||||
  • Base64-encoded strings can be decoded by anyone using numerous free online tools, so I wouldn't use it to hide/protect sensitive information. – Mark G Jul 17 '19 at 16:05

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.