0

We want to remove the EMAIL ADDRESS within the URL string from our Preference Centre links within email. Our initial thought was to encode using BASE64 or to simply use the "Send Context" when deploying quoting the microsite page ID.

While the microsite pages work, once we place these into our site via an iFrame all of the AMPscript stops working and we can't pull in the Email Address to load the subscriber info.

Is there a way to leverage AMPscript within an iFrame so that the AMPscript continues to work?

3 Answers 3

1

How will end-users arrive on the microsite? If coming from a link in an email footer, then using MicrositeURL() function in the email ampscript would be best practice. If arriving on the page from an external link, then you will need to pass the email address as part of the querystring.

The below code will work for both scenarios.

%%[
var @email
set @email = emailaddr
IF EMPTY(@email) THEN
   set @email = requestParameter("e")
   IF NOT IsEmailAddress(@email) THEN
    set @email = Base64Decode(@email)
   ENDIF
ENDIF
]%%
2
  • The URL in the footer is to the actual landing page, in which the microsite loads via the iFrame. Therefore, the URL is not to the microsite, but is referenced on the webpage that is calling the microsite via the iFrame. Dec 29, 2017 at 20:06
  • I see. So, I would treat this as an external site . I would pass the base64encoded email as a parameter to the external landing page. Then from this landing page, I would grab the email parameter and pass it back 'as is' to the microsite via the iframe. If setup this way, the above code sample should still work. Dec 31, 2017 at 3:44
0

I think there are a couple of questions here:

  1. Passing email address encoded. I've started using the MicrositeURL() function after reading this article from Adam Spriggs. https://sprignaturemoves.com/a-case-for-the-micrositeurl-function/

  2. How do you get the passed parameters from a parent to the iFrame? You could try something like this. https://stackoverflow.com/questions/7962646/how-to-get-the-querystring-from-a-parent-page

1
  • I have used #1, and it works on the microsite itself, but I have yet to test it within the iFrame. For #2, I will try that and see what happens... I'm unfortunately quite a newb when it comes to this stuff! Dec 27, 2017 at 19:30
0

It turns out there are TWO places to decode the email address in the preference centre. Once, using AMPscript and Base64Decode within the iFrame and once using Javascript on the Preference Centre "shell" that hosts the iFrame.

Therefore, we pull in the encoded email via QUERYPARAMETER("email"),

SET @encodeemail=QUERYPARAMETER("email")
SET @email = Base64Decode(@encodeemail,"utf-8")

and also with the Javascript:

if (email != "") {
if (!EmailValidation(email)) {           
        $("#EMAIL_ADDRESS_").val(BaseDecode(email));
    }
    else {
        $("#EMAIL_ADDRESS_").val(email);
    }

I apologize if this isn't super clear - I'm a total newb on JS

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.