Mailchimp - how can I tell if a user has unsubscribed themselves?

橙三吉。 提交于 2019-12-24 03:15:31

问题


So they've clicked the unsubscribe link in a newsletter. In their profile it says, for example:

This person unsubscribed on Mar 24, 2017 2:40 pm

After receiving "Newsletter Test#6"

Great, but how can I tell programmatically, via the API, if someone has unsubscribed themselves? Is it even possible? The reason I'm asking is because you can't delete someone who has unsubscribed themselves. If you try, their data will be scrubbed but the email address will stay in your list. Furthermore, if you try to subscribe someone who has unsubscribed by clicking on an unsubscribe link, you'll get "john@example.com is in a compliance state due to unsubscribe, bounce, or compliance review and cannot be subscribed." So in this situation we should check if they've unsubscribed themselves, and if so we can set their status to pending which will send the confirmation opt-in email. Otherwise, we can subscribe them via API without setting their status to pending and sending them an email and requiring them to click the link in the email.


回答1:


As you've noted, if you try to delete someone in a compliance state, the API will reject your request but unfortunately doesn't return any useful response indicating as such. On the other hand, if you try to subscribe someone in a compliance state you should get a response in json form with status of 400 and a corresponding message. In my case it looks something like this:

{
    "type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
    "title":"Member In Compliance State",
    "status":400,
    "detail":"johndoe@example.com is in a compliance state due to unsubscribe, bounce, or compliance review and cannot be subscribed.",
    "instance":"1234567890abcdefg"
}

If you simply parse that response you can check for the value of status which is probably more reliable and forward compatible than the textual descriptors - and if applicable you can set member state to pending from there.




回答2:


From Mailchimp support:

When a user is unsubscribed you'll see the parameter unsubscribe_reason and if it's an admin unsubscribe or an unsubscribe done via the API it will say "N/A (Unsubscribed by an admin)". However if it is done by the user it will often say "Unspecified" if they did not leave a reason or it may display a reason the user noted for unsubscribing. You can read more about the unsubscribe_reason parameter at the link below.

http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/



来源:https://stackoverflow.com/questions/42990336/mailchimp-how-can-i-tell-if-a-user-has-unsubscribed-themselves

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!