I want to add my subscriber different segment by signup source. I create two segment in Mailchimp. How can I add that subscribe to different segments? I using API v2.
<?php include('MailChimp.class.php'); $MailChimp = new DrewmMailChimp('ebae376c690e50d98ce069482eec5244-us8'); $result = $MailChimp->call('lists/subscribe', array( 'id' => 'fde03148a4', 'email' => array( 'email' => $_POST['email'] ), 'merge_vars' => array( 'MERGE2' => $_POST['name'] // MERGE name from list settings // there MERGE fields must be set if required in list settings ), 'double_optin' => true, 'update_existing' => false, 'replace_interests' => false )); if( $result === false ) { // response wasn't even json } else if( isset($result->status) && $result->status == 'error' ) { echo $result->status, $result->code, $result->name, $result->error; } ?>
Advertisement
Answer
From the API Docs: you’ll need to add a groupings
item to your merge_vars
array. That should be an array of associative arrays with id
and a groups
array with the names of the groups you want to add the user to.
In v3, this is a good bit easier. There’s an interests
object that just takes IDs and Booleans to determine if a user is added to or removed from a group.