1

I am looking to pull the status of a subscriber whenever they click on the profile center URL link within emails. I have created a custom profile center that pulls all of the lists that I have created onto the page, but I am looking to have another column to tell the user that they are already active or unsubscribed to a list. I have tried using AMPscript but it did not seem to work, so I am looking for a way to pull these statuses using SSJS and then printing it out on the HTML page for the user to see.

If you need any more details, let me know!

0
1

Use the following code to determine which Lists (also Publication Lists) a subscriber is a part of.

Make sure your email is using %%=MicrositeURL(xxxxx)=%% or %%=RedirectTo(CloudPagesURL(xxxxx))=%%.

This ensures that the Landing Page/CloudPage has access to the subscriber's attributes (such as Subscriber Key)

%%[
    SET @subscriberKey = _subscriberkey /*Retrieve the Subscriber Key into a variable*/
]%%

<script runat="server">
    Platform.Load("core", "1.1.1")
    var subKey = Variable.GetValue("@subscriberKey") //Assign to SSJS variable
    var subObj = Subscriber.Init(subkey) //Initiate Subscriber Object
    
    var listJSON = subObj.Lists.Retrieve() //Retrieve lists that the subscribers is a part of
    for (var i = 0; i < listJSON.length; i++){ //Loop through all the lists and print them out in HTML
    
        var listName = listJSON[i]["List"]["Name"]
        var listStatus = listJSON[i]["Status"]
 </script>
 
 <body>
 
     List Name:<ctrl:var name=listName /> <br />
     List Status:<ctrl:var name=listStatus /> <br />
     
 </body>
 
<script runat="server">
    Platform.Load("core", "1.1.1")    
    } //End of loop
    
    Write("Debug - Subscriber JSON:" + Stringify(listJSON)) //Used for debugging to find the object names
    
 </script>

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.