1

I'm trying to use SSJS on a microsite landing page to pull in personalization strings and variables from an email. I tried using both the MicrositeURL() AMPscript function and the microsite_base_url personalization string as the account I'm working on is not 2.0.

The result of the below code are variables that are undefined.

Relevant email code:

    <body>
%%[
VAR @var

SET @var = 1
]%%
<br><br>
Microsite URL: <a href="%%=MicrositeURL(825318)=%%" >this</a>
<br>
Microsite_base_url: <a href="%%microsite_base_url[default]825318[/default]%%" >this</a> 

</body>

Here is the SSJS on the microsite page:

<script runat="server" language="javascript">
    Platform.Load('Core', '1');

    var subscriberkey = Variable.GetValue('_subscriberkey');
    var emailaddress = Variable.GetValue('emailaddr');
    var jobid = Variable.GetValue('jobid');
    var batchid = Variable.GetValue('_JobSubscriberBatchID');
    var listid = Variable.GetValue('listid');
    var istestsend = Variable.GetValue('_IsTestSend');
    var optoutflag = Variable.GetValue('@optoutflag');
</script>

<body>    
<p>
       SubscriberKey: <ctrl:var name=subscriberkey /><br>
       EmailAddress: <ctrl:var name=emailaddress /><br>
       JobID: <ctrl:var name=jobid /><br>
       BatchID: <ctrl:var name=batchid /><br>
       ListID: <ctrl:var name=listid /><br>
       IsTestSend: <ctrl:var name=istestsend /><br>
       OptOutFlag: <ctrl:var name=optoutflag /><br>
                             </p>
</body>

The body of the landing page spits out "undefined" for the variables.

SubscriberKey: undefined
EmailAddress: undefined
JobID: undefined
BatchID: undefined
ListID: undefined
IsTestSend: undefined
OptOutFlag: undefined

I am able to pull in these variables with AMPscript, so I may need to use AMP instead of SSJS if I can't figure this out.

Please help! Thank you.

1

You should be using the Attribute.GetValue() function to retrieve the personalization string values:

<script runat="server" language="javascript">
    Platform.Load('Core', '1');

    var subscriberkey = Attribute.GetValue('_subscriberkey');
    var emailaddress = Attribute.GetValue('emailaddr');
    var jobid = Attribute.GetValue('jobid');
    var batchid = Attribute.GetValue('_JobSubscriberBatchID');
    var listid = Attribute.GetValue('listid');
    var istestsend = Attribute.GetValue('_IsTestSend');
    var optoutflag = Variable.GetValue('@optoutflag');
</script>

I have a custom preference center boilerplate that you might find helpful.

  • Thanks for sharing, Adam. I made the updates and can now get the personalization strings to come through. However, still having issues with the variables. Both of the following are coming up as undefined: Variable.GetValue("@optoutflag") and Request.GetQueryStringParameter("optoutflag") – Daniel Jun 14 '16 at 0:52
  • Variable.GetValue() is for retrieving AMPScript variables previously set, and Request.GetQueryStringParameter() is for retrieving URL parameters. Based on your example, you don't need either of those, just Attribute.getValue(), since the sending DE columns (and Profile Attributes) are present via the QS parameter in your microsite URL. – Adam Spriggs Jul 12 '16 at 14:02

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.