1

I have currently build a microsite page that, when accessed by a Subscriber by clicking a link in an email, automatically loads data from a data extension relating to that subscriber.

This is done using the _SubscriberKey standard field.

I am trying to build a similar page, where the subscriber key is entered manually, and so can be used by our service agents, but I can't figure out how to let them enter a key that is then passed to the next page as a variable.

Does anyone know how to pass a variable from one page to another?

Thanks

1 Answer 1

0

You'll need to do a form post and then retrieve the value from the input box.

There are some details on how to do that in my preference center boilerplate example:

<script type="text/javascript" runat="server">

    Platform.Load("core", "1.1.1");

    var debug = false;
    var request = {};
    SetVar("urlThis", Platform.Request.RequestURL);

    if (Request.Method == "GET") {

        if (debug) {
            Write("GET<br/>");
        }

        // retrieve values from the subscriber context or URL parameters using Attribute.GetValue("VARNAME") or Request.GetQueryStringParameter("VARNAME");

        // in your email, use the AMPScript MicrositeURL() function with the landing page page id to ensure the subscriber context is passed to your landing page

        // set AMPScript variables using the SetVar function below


    } else if (Request.Method == "POST") {

        if (debug) {
            Write("POST<br/>");
        }

        // retrieve POST values using Request.GetFormField("VARNAME")

        // do the appropriate API call

        // redirect to the RESULTURL based on success or failure of API call

        Redirect(RESULTURL,false);
    }


    function SetVar(varName, varValue){
        request[varName] = varValue;
        Variable.SetValue(varName, varValue);
    }

    function isEmpty(str) {
      return (!str || 0 === str.length);
    }
    if (debug) {
        Write("<br><br>debug output: " + Stringify(request));
    }


</script><!DOCTYPE HTML>
<html>
    <head></head>
    <body>
      <form id="formName" action="%%=v(@urlThis)=%%" method="post" enctype="application/x-www-form-urlencoded">
        default form values with %%=v(@VARNAME)=%% or <ctrl:eval>VARNAME</ctrl:eval>
      </form>
    </body>
</html>

There's also a simple AMPScript example in Macca's answer on another post:

%%[ IF @@ExecCtx == "LOAD" THEN]%%
    <form action="%%=RequestParameter('PAGEURL')=%%"> method="post">
        Name: <input type="text" name="name"><br>
        Email: <input type="text" name="email"><br>
        <input type="submit">
    </form>
%%[ ELSEIF @@ExecCtx == "POST" THEN]%%
    %%[/*Handle post here*/]%%
%%[ENDIF]%%
1
  • 1
    Thank you, that worked perfectly, I now have a functioning search and update microsite!
    – Gareth
    Commented Sep 27, 2017 at 9:37

You must log in to answer this question.

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