php - How can I add that subscribe to different segments? -
i want add subscriber different segment signup source. create 2 segment in mailchimp. how can add subscribe different segments? using api v2.
<?php include('mailchimp.class.php'); $mailchimp = new \drewm\mailchimp('ebae376c690e50d98ce069482eec5244-us8'); $result = $mailchimp->call('lists/subscribe', array( 'id' => 'fde03148a4', 'email' => array( 'email' => $_post['email'] ), 'merge_vars' => array( 'merge2' => $_post['name'] // merge name list settings // there merge fields must set if required in list settings ), 'double_optin' => true, 'update_existing' => false, 'replace_interests' => false )); if( $result === false ) { // response wasn't json } else if( isset($result->status) && $result->status == 'error' ) { echo $result->status, $result->code, $result->name, $result->error; } ?>
from api docs: you'll need add groupings
item merge_vars
array. should array of associative arrays id
, groups
array names of groups want add user to.
in v3, bit easier. there's interests
object takes ids , booleans determine if user added or removed group.
Comments
Post a Comment