Salesforce Asked on December 19, 2021
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!
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>
Answered by Gortonington on December 19, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP