0

I'm trying to create a cloud page that will unsubscribe someone from a publication list if they click the link. I do not want to change their status in All Subscribers, and I don't need to include any tracking information about the job. Based on the documentation, this code should simply change the status of my test subscriber from "Active" to "Unsubscribed", but it won't work. If I try to write the status, it just says "error". What am I missing??

        <script runat="server">    
            Platform.Load("core", "1");
            var subkey64 = Request.GetQueryStringParameter("s");
            var subkey = Platform.Function.Base64Decode(subkey64);
            var pubList = List.Init("1234");
            var status = pubList.Subscribers.Unsubscribe(subkey);
        </script>

1 Answer 1

3

I saw many times the official documents were incorrect so I would recommend that you may need to research from various sources.

Based on your code above, I assume you can get the list ID for a publication list so you can get the list customer key as well.

<script runat="server">
    
    Platform.Load("core", "1");
    var subkey64 = Request.GetQueryStringParameter("s");
    var subkey = Platform.Function.Base64Decode(subkey64);
    var pubList = List.Init("Your list customer key");
    var status = pubList.Subscribers.Update({"SubscriberKey": "Your subscriber key"} ,"Unsubscribed");
    
</script>

Reference: Subscribers Update

You must log in to answer this question.

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