如何将订阅添加到不同的细分市场?

How can I add that subscribe to different segments?

我想按注册来源添加我的订户不同的细分市场。我在 Mailchimp 中创建了两个部分。如何将订阅添加到不同的细分市场?我使用 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 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;
}
?>

来自 API Docs:您需要将 groupings 项添加到 merge_vars 数组。那应该是一个包含 id 的关联数组数组和一个 groups 数组,其中包含您要将用户添加到的组的名称。

在 v3 中,这要容易一些。有一个 interests 对象只需要 ID 和布尔值来确定用户是添加到组还是从组中删除。