MailChimp’s API is great for getting/updating data about campaigns, lists, and users. One would think that, because the API exposes so much campaign information, it would also be exposing autoresponder information, since they are just a type of campaign.
One would be sorely mistaken.
Recently, I needed to create a daily email report that would use MailChimp’s API to get the number of recipients for each autoresponder for that day. It was going to be an easy project, up until I realized that MailChimp would let me access almost all of the information I needed – the campaigns, the segment criteria, the users – except for the information about who was going to receive the email that day.
This functionality is something that is offered on their site proper, though, so it is possible. The “Who’ll Get This Next” link in the send settings of the autoresponder’s row on the autoresponder page will show who is going to get the email that day. If no one fits the criteria for today, then the result set comes up empty, so “Who’ll Get This Next” should probably be called something like “Who’ll Get This Today,” but I’m not here to pick on their copy choices.
In any case, I needed to get the number of users who were going to receive an autoresponder sent out three days after they signed up for the newsletter, which meant I needed to figure out there signup date. Because of the way the other merge vars were set up, it wasn’t clear which one of them was the signup date, or if any of them actually were. (Read: I still have no idea.)
MailChimp’s API documentation is pretty great, and has examples for each function, but the examples don’t always cover every bit of available functionality, so it wasn’t until about the third time that I read the campaignSegmentTest function documentation that it finally clicked that the field ‘date’ they were talking about was the date a user signed up. And, honestly, I found that whole section of the page kind of confusing at first, because the way the information was laid out didn’t make much sense to me.
But enough about my lack of reading comprehension. For anyone else out there who is trying to figure out how to get the number of “Who’ll Get This Next” from their MailChimp autoresponder based on the signup date, it turns out it is wicked simple. My site is in PHP, so this is the PHP code to do it:
//This takes today's date in POSIX/Unix Time and subtracts three days from it, then converts that to a string in the format 'YYYY-MM-DD', which is the format that the date field for campaignSegmentTest requires.
$date = date('Y-m-d', strtotime('-3 days'));
//This creates a condition that the sign up date must equal the three-days-ago date just calculated
$signup_cond = array('field' => 'date', 'op' => 'eq', 'value' => $date);
This means that the full array to pass to campaignSegmentTest for a JSON call would look something like this:
'list_id' => $the_list_id,
'options' => array(
'match' => 'all',
'conditions' => array(
It seemed pretty dang complicated the first time I had to put it all together, but now I’ve started to get the hang of it… just as the project is ending. I hope this helped someone else figure out how to get “Who’ll Get This Next” autoresponder numbers from MailChimp!