0

I have a question with base64decode function.

The following variables are not getting decoded when passed in the cloud pages. In email I am using following ampscript.

Email

%%[ 

VAR @Member_Number, @Email_Address,@LPURL 
SET @Member_Number = Base64Encode(MemberNumber) 
SET @Email_Address =Base64Encode(EmailAddress) 
SET @LPURL = Concat('http://example.com/page.aspx?EmailAddress=',@Email_Address,'&Member_Number=',@Member_Number)

]%%
%%=RedirectTo(@LPURL)=%%

When someone clicks, on above following gets captured in landing page. I am using insertdata function to capture the subscribers details. However when I click on the records in DE, they are still coming as encrypted.

Landing Page

%%[

VAR @Member_Number, @Email_Address, @ClickDate
/* Get Data From DE */
SET @Member_Number = RequestParameter("Member_Number")
Set @Member_Number1 = Base64Decode(@Member_Number)
SET @Email_Address = RequestParameter("EmailAddress")
SET @Email_Address1 = Base64Decode(@Email_Address)
SET @ClickDate = Format(SystemDateToLocalDate(NOW()),"yyyy-MM-dd HH:mm:ss")

IF NOT EMPTY(@Member_Number) THEN

   InsertData("LandingPageDE","MemberNumber", @Member_Number1, "EmailAddress", @Email_Address1, "ClickDate", @ClickDate)

ENDIF
]%%
1
  • Can you confirm the Base64Encode has worked in the Email - does the URL have the correctly encoded values? You also haven't declared @Member_Number1 as a variable. Commented Mar 11, 2017 at 12:17

1 Answer 1

1

Base64 Encoded strings typically contain + and = characters, so you will need to URL encode your Base64 strings if you are going to use them as URL parameters.

Try this:

%%[ 
VAR @Member_Number, @Email_Address,@LPURL 
SET @Member_Number = Base64Encode(MemberNumber) 
SET @Email_Address = Base64Encode(EmailAddress) 
SET @LPURL = Concat('http://example.com/page.aspx?EmailAddress=',URLEncode(@Email_Address),'&Member_Number=',URLEncode(@Member_Number))
]%%
%%=RedirectTo(@LPURL)=%%

AMPscript should decode any URL encoded strings (which is probably why there is no URLDecode AMPscript function).

However, I am curious to find out why you are Base64 encoding the strings in the first place (and not just using URLEncoding). If it's for 'security' then Base64Encode is really only "security through obscurity" and not a good idea. You would be better off using EncryptSymmetric and DecryptSymmetric if you want to obfuscate these parameters.

4
  • Hi @Eliot Thank you for looking into this. I amended the ampsript as follows: In Email ` %%[ VAR @Member_Number, @Email_Address,@LPURL SET @Member_Number = Base64Encode(MemberNumber) SET @Email_Address = Base64Encode(EmailAddress) SET @LPURL = Concat('example.com/…) ]%% %%=RedirectTo(@LPURL)=%% `
    – Chandan
    Commented Mar 12, 2017 at 22:31
  • In landing page following is used: %%[ VAR @Member_Number, @Email_Address, @ClickDate /* Get Data From DE */ SET @Member_Number = RequestParameter("Member_Number") SET @Email_Address = RequestParameter("EmailAddress") SET @ClickDate = Format(SystemDateToLocalDate(NOW()),"yyyy-MM-dd HH:mm:ss") IF NOT EMPTY(@Member_Number) THEN InsertData("LandingPageDE","MemberNumber", @Member_Number, "EmailAddress", @Email_Address, "ClickDate", @ClickDate) ENDIF ]%% But still the data inserted in data extension is encrypted.
    – Chandan
    Commented Mar 12, 2017 at 22:44
  • Odd, that should work. Please can you drop me an email [email protected] and let me know your availability so we can look at this together on a brief webinar, then I can update my answer to based on the solution. Commented Mar 13, 2017 at 17:23
  • @Chandan, you would be much better off using the CloudPagesURL AMPscript funtion which passes parameters in an encrypted string to your Cloud Page. Also you can get the email address in your CloudPage simply by using the personalisation string emailaddr instead of setting it as a variable, as it is automatically passed to the CloudPage from the AMPscript function. Commented Apr 27, 2017 at 7:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .