0

What is the best way to delete subscribers from SFMC automatically when I

Use something like this on a cloud page

%%[
var  @sid, @jid, @reason, @lue, @lue_prop, @lue_statusCode, @overallStatus, @requestId, @Response, @Status, @Error, @insert, @id, @result, @email

SET @id = Trim(RequestParameter("id"))

SET @result = UpdateSingleSalesforceObject('Contact', @id, 'E_Mail_Opt_In_confirmed__c', 0, 'HasOptedOutOfEmail', 1)


SET @sid = RequestParameter("email")
SET @jid = RequestParameter("jobid")
SET @listid = "185"
SET @reason = "Cloud Page Unsubscribe"
SET @lue = CreateObject("ExecuteRequest")
SetObjectProperty(@lue,"Name","LogUnsubEvent")
SET @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
SetObjectProperty(@lue_prop, "Value", @sid) AddObjectArrayItem(@lue, "Parameters", @lue_prop)
SET @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "JobID")
SetObjectProperty(@lue_prop, "Value", @jid)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)
SET @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "ListID")
SetObjectProperty(@lue_prop, "Value", @listid)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)
SET @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "BatchID")
SetObjectProperty(@lue_prop, "Value", @batchid)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)
SET @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "Reason")
SetObjectProperty(@lue_prop, "Value", @reason)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)
SET @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)
SET @lue_Response = Row(@lue_statusCode, 1)
SET @lue_Status = Field(@lue_Response,"StatusMessage")
SET @lue_Error = Field(@lue_Response,"ErrorCode")

]%%

Or just this

%%[ var @id, @result

SET @id = Trim(RequestParameter("id"))

SET @result = UpdateSingleSalesforceObject('Contact', @id, 'E_Mail_Opt_In_confirmed__c', 0, 'HasOptedOutOfEmail', 1) ]%%

First code turns a subscriber in All subscribers in status unsubscribe. Re-subscribe seems not to be possible.

Second case just updates the Optin Status in Sales Cloud. The data stream only allows customers with opt-in status true. The sync overwrites existing data.

In both cases how can I manage to delete subscribers automatically from All subscriber?

Thanks!

  • Do you mean Delete Delete, as in completely remove all trace of this person from your SFMC instance? or do you want to just remove them from being sendable - as most of what you show is to unsubscribe the person? Please note that if deleting them it opens the potential for them to be added in and sent again (breaking CAN-SPAM, etc.) if using SFMC as the DataBase of Record on Subscription status as their associated status and history would be removed upon deletion. – Gortonington Mar 28 '19 at 15:03
0

The resubscribe issue might be solved by an additional update to the subscriber list on the DOI confirmation page to reactive him:

%%[
  SET @Subscriber = CreateObject("Subscriber")
  SetObjectProperty(@Subscriber, "SubscriberKey", @SubscriberKey)
  SetObjectProperty(@Subscriber, "EmailAddress", @EmailAddress)
  SetObjectProperty(@Subscriber, "Status", "Active" )
  InvokeUpdate(@Subscriber, @createErrDesc, @createErrNo, @createOpts)
]%%
| improve this answer | |
0

If you do want to hard-delete with all the consequences and potential pitfalls, you probably will have to use the API called from an SSJS Script Activity in Automation Studio for this, e.g. - select all the relevant data into a data extension, and then run this API Call, say, daily.

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/DeleteByListReference.htm

on a sidenote: re-subscription on all subscribers is possible, but that's probably best solved in another thread. With this in mind though, it does begs the question if deletion is the right thing to do in case 1.

As for case two, I like to keep the decision which records get through the MC Connect boolean synch filter separated from the opt ins. The reason is, as was rightly pointed out in the discussion, that there is a point in Marketing cloud storing the opt out persistently.

| improve this answer | |

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.