0

as the title says I'm looking for the best option to use code to unsubscribe a user from all business units. More specifically, we're planning to build a custom preference center that would basically give the end-user the option to either unsubscribe from a certain BU or all BUs.

Off the top of my head, i'm thinking of using WSproxy to update the Subscriber Object via API, but subscriber management's a bit new to me, so wanted to check with everyone!

Thanks!

2

What I would recommend using, due to its versatility is LogUnsubEvent.

Although it is created to handle job specific events and BUs, I find it is the best option because if you leave all of that off, it will master unsubscribe.

Find more info on LogUnsubEvent inside this article I wrote as well as one that Zuzanna wrote that includes how to do it in multiple SFMC languages.

My recommended WSProxy script:

<script runat="server">
    function LogUnsubEvent(mid,skey,emailaddr,jId,lId,bId,unsubReason) {
    var prox = new Script.Util.WSProxy();

    /* Set ClientID */
        if(mid) {
      prox.setClientId({ "ID": mid}); //Impersonates the BU
        }

    var props = [
       { Name: "SubscriberKey", Value: sKey },
       { Name: "EmailAddress", Value: emailAddr },
       { Name: "JobID", Value: jId },
       { Name: "ListID", Value: lId },
       { Name: "BatchID", Value: bId },
       { Name: "Reason", Value: unsubReason }

    ];
    var data = prox.execute(props, "LogUnsubEvent");
        return data;
    }
</script>
| improve this answer | |
  • Thanks Gortonington - this is exactly what i need! Cheers! – balwill Jul 24 at 13:25

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.