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


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
   set @email = requestParameter("e")
   IF NOT IsEmailAddress(@email) THEN
    set @email = Base64Decode(@email)
  • 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. Commented 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. Commented Dec 31, 2017 at 3:44

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

  • 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! Commented Dec 27, 2017 at 19:30

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)) {           
    else {

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

You must log in to answer this question.

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