0

currently trying to establish a sufficient process in Salesforce marketing cloud that when a user unsubs from an email sent to a list/DE that the user is unsubbed from all lists the user is in and/or may be in in the future. of course, the user can unsub from ALL communications but they have to click an extra box in the unsub preference center, at the very bottom of the page, which is an extra step and they may miss it.

I believe this is called an account unsubscribe tier. Right now, users are unsubbed at the list level tier and we want it to be unsubbed at the account level.

https://salesforce.blog/2020/08/unsubscribe-levels-in-salesforce-marketing-cloud.html

https://help.salesforce.com/articleView?id=sf.mc_es_how_a_subscriber_opts_out.htm&type=5

Any thoughts? I heard we may need an automation for this?

Thank you in advance!

0

Nice name! :D, this is a pretty generalized question so apologies for the lengthy response.

The big question I have is are you using lists or Data Extensions?

Data Extensions: If you are using data extensions with one mail stream then an unsubscribe would be handled at the all subscribers level where they would be unsubscribed from all further publications. This is probably the simplest way to unsubscribe people at an all-subscriber level. If you have multiple business units ensure that they are configured to unsubscribe users from all business units, this will trickle up to the main all subscribers list.

Lists: If you are using lists then I would try use the API to unsubscribe users at the all-subscribers list, this will then trickle down to all lists the subscriber key is associated with. This can be accomplished by moving your unsubscribe page to a custom cloud page that fires the API on load.

There is two APIs that would work to accomplish this.

  1. WSProxy API- this is probably the simplest API to use (Note that this API will only work on the master business unit, if you are trying to unsubscribe to all subscribers and the cloud page is hosted on a child BU this will not work.)

Here is a snippet on WSProxy to log an unsubscibre event, Gortonington has a great article about this API here: https://gortonington.com/logunsubevent-and-how-to-do-it-in-wsproxy/

  <script runat="server">
    Platform.Load("Core", "1.1.1");

    var subkey = Attribute.GetValue("_subscriberkey");
    var jid = Attribute.GetValue("jobid");
    var bid = Attribute.GetValue("_JobSubscriberBatchID");
    var prox = new Script.Util.WSProxy();

    var props = [{
        Name: "SubscriberKey",
        Value: subkey
      },
      {
        Name: "JobID",
        Value: jid
      },
      {
        Name: "BatchID",
        Value: bid
      },
      {
        Name: "Reason",
        Value: "WSProxy one click unsubscribe"
      }
    ];

    try {
      var data = prox.execute(props, "LogUnsubEvent");
      //Write(Stringify(data));
    } catch (e) {
      //Write(Stringify(e));
    }
  1. SOAP API - if you are using a child business unit cloud page you will have to use the SOAP API with the client authentication from the Master Business Unit. You will need to create an app that allows read/write to subscribers. Here is a script to fetch AuthToken and run SOAP unsub.
<script language='javascript' runat=server>
Platform.Load("Core", "1.1.1");

  try {
    var success = false;
    var accessToken = GetAccessTokenForAPI(clientId, clientSecret, grantType);
    if (accessToken != null) {
      success = UpdateSub(subscriberKey, emailAddress, accessToken, eventDefinitionKey);
    }
    if (success) {

    } else {

    }
  } catch (ex) {

  }

  function GetAccessTokenForAPI(clientId, clientSecret, grantType) {
    var url = '{{your endpoint}}';
    var contentType = 'application/json';
    var payload = {
      client_id: clientId,
      client_secret: clientSecret,
      grant_type: grantType

    };

    var accessTokenRequest = HTTP.Post(url, contentType, Stringify(payload));
    if (accessTokenRequest.StatusCode == 200) {
      var tokenResponse = Platform.Function.ParseJSON(accessTokenRequest.Response[0]);
      return tokenResponse.access_token;
    } else {
      return null;
      Write("Error");
    }

  }

  function UpdateSub(subscriberKey, emailAddress, accessToken, eventDefinitionKey) {
    var payload = '';
    var endpoint = "{{your endpoint}}}}";
    var result;

    payload += '<?xml version="1.0" encoding="utf-8"?>';
    payload += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
    payload += '  <soapenv:Header>';
    payload += '     <fueloauth xmlns="http://exacttarget.com">' + accessToken + '</fueloauth>';
    payload += ' </soapenv:Header>';
    payload += '  <soapenv:Body>';
    payload += '   <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">';
    payload += '        <Options>';
    payload += '           <SaveOptions>';
    payload += '              <SaveOption>';
    payload += '                 <PropertyName>*</PropertyName>';
    payload += '                 <SaveAction>UpdateOnly</SaveAction>';
    payload += '              </SaveOption>';
    payload += '           </SaveOptions>';
    payload += '        </Options>';
    payload += '        <Objects xsi:type="Subscriber">';
    payload += '           <PartnerKey xsi:nil="true" />';
    payload += '           <ObjectID xsi:nil="true" />';
    payload += '           <Status>Inactive</Status>';
    payload += '           <SubscriberKey>' + subscriberKey + '</SubscriberKey>';
    payload += '        </Objects>';
    payload += '     </UpdateRequest>';
    payload += '  </soapenv:Body>';
    payload += '</soapenv:Envelope>';

    try {
      result = HTTP.Post(endpoint, "text/xml", payload, ["SOAPAction"], ["Update"]);
      Write(Stringify(result));
    } catch (e) {
      Write(Stringify(e));
    }
  }
</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.