▶ Watch related videos on YouTube — Search results for: Retrieving unsubreason field from subscribers in Salesforce Marketing Cloud
Understanding the Platform
The SubscriberStatusEvent object in Salesforce Marketing Cloud provides a way to retrieve information about subscriber status changes, including unsubscribes. By using the SOAP API to query this object, you can retrieve the unsubReason field for subscribers who have opted out of all business units.
Retrieving unsubReason Field
To retrieve the unsubReason field, you will need to use the SOAP API to query the SubscriberStatusEvent object. The following code snippet demonstrates how to do this:
RetrieveUnsubReason.java
SoapClient client = new SoapClient();
SubscriberStatusEvent[] events = client.retrieve(SubscriberStatusEvent.class, new String[] { "unsubReason" });
for (SubscriberStatusEvent event : events) {
System.out.println(event.getUnsubReason());
}
The root cause of the issue is the lack of a straightforward way to retrieve the unsubReason field for subscribers who have unsubscribed from all business units. The _BusinessUnitUnsubscribe data view is not an option when using the setting to unsubscribe from all BUs, and using a data extract or undocumented API is not preferred.
Best Practices
When retrieving the unsubReason field, keep in mind that this method only works for subscribers who have unsubscribed from all business units. If you need to retrieve the unsubReason field for subscribers who have unsubscribed from a specific business unit only, you will need to use the _BusinessUnitUnsubscribe data view.
Heads up: Make sure to handle any exceptions that may occur when using the SOAP API to retrieve the unsubReason field.
Checklist
- Use the SOAP API to query the SubscriberStatusEvent object
- Retrieve the unsubReason field for subscribers who have unsubscribed from all business units
- Use the _BusinessUnitUnsubscribe data view for subscribers who have unsubscribed from a specific business unit only
- Handle any exceptions that may occur when using the SOAP API
- Test your code thoroughly to ensure it is working as expected
Frequently Asked Questions
What is the SubscriberStatusEvent object?
The SubscriberStatusEvent object provides a way to retrieve information about subscriber status changes, including unsubscribes.
Can I use the _BusinessUnitUnsubscribe data view to retrieve the unsubReason field?
No, the _BusinessUnitUnsubscribe data view is not an option when using the setting to unsubscribe from all BUs.
What is the difference between unsubscribing from all business units and unsubscribing from a specific business unit only?
Unsubscribing from all business units means the subscriber will be removed from all business units, while unsubscribing from a specific business unit only means the subscriber will be removed from that specific business unit.
Can I use the SOAP API to retrieve the unsubReason field for subscribers who have unsubscribed from a specific business unit only?
No, the SOAP API can only be used to retrieve the unsubReason field for subscribers who have unsubscribed from all business units.
Need help shipping this in production?
Genetrix builds and untangles Salesforce Marketing Cloud and Agentforce setups for teams that want it done right the first time. If anything in this post sounds familiar, talk to us before it ships.