A case for the MicrositeURL() function

Do you know about the MicrositeURL() AMPScript function? It’s relatively new. It sure is handy if you’re building custom preference centers in Enterprise 2.0 business units.

The idea is that you can encrypt custom parameters in your email links to Microsite pages and then retrieve the unencrypted values with an AMPScript function. Once you have the business unit MID in the microsite page, you can use it to ensure your API calls are for the correct business unit.

In your email you would have this code:

<a href='%%=MicrositeURL(888888,"subscriberMID", "12345678")=%%'>Update Profile</a>

The 888888 is the Page ID of the Microsite page, and 12345678 is the business unit MID for the originating email send.

In your Microsite page, you’d have the following AMPScript block:

%%[
var @subscriberMID
set @subscriberMID = iif(empty(RequestParameter("subscriberMID")),memberid, RequestParameter("subscriberMID"))
]%%

In the case where the the subscriberMID is not set, default to the parent business unit’s MID, which is accessible from the memberid personalization string.

One gotcha: If you build your custom preference centers with Server-Side Javascript, there’s no SSJS function to retrieve the additional MicrositeURL parameters — you to use AMPScript. Your code may end up looking something like this:

<script type="text/javascript" runat="server">
    Platform.Load("core", "1.1.1");
    </script>%%[set @subscriberMID = RequestParameter("subscriberMID")]%%<script type="text/javascript" runat="server">

    if (Variable.GetValue("@subscriberMID") != "") {
        memberid = Variable.GetValue("@subscriberMID");
    } else {
        memberid = Attribute.GetValue("memberid");
    }
</script>

For further reading:
MicrositeURL()
RequestParameter()
Personalization Strings
Server-Side JavaScript