【问题标题】:Create campaign with dynamic segment using MailChimp API V3.0使用 MailChimp API V3.0 创建具有动态细分的营销活动
【发布时间】:2016-06-17 13:15:26
【问题描述】:

使用 MailChimp API V3.0 创建活动。

我想制作一个发送给具有特定兴趣的用户的广告系列。看起来这在文档中是可能的,但我已经尝试了我能想到的所有排列。只要我省略了 segment_ops 成员,我就可以很好地创建活动。有没有人有 PHP 代码的例子可以做到这一点?

似乎兴趣被奇怪地处理了,因为您在通过 API 设置用户兴趣时没有包含兴趣类别。我不确定这会如何影响广告系列的制作。

【问题讨论】:

  • 似乎是您的 MailChimp 代表的问题
  • 这是一个免费的 MailChimp 帐户,音量非常小,所以不支持。我在这里找到了许多其他关于 MC API 的有用答案,因此希望这样做的人会发布一个工作示例。

标签: php mailchimp segment mailchimp-api-v3.0


【解决方案1】:

我已经让这个工作了,API 定义可以在这里找到https://us1.api.mailchimp.com/schema/3.0/Segments/Merge/InterestSegment.json

必须将兴趣分组在兴趣类别下(在 UI 的某些部分称为“组”)。

这是收件人数组的 segment_opts 成员的 JSON:

 "segment_opts": {
        "match": "any",
        "conditions": [{
            "condition_type": "Interests",
            "field": "interests-31f7aec0ec",
            "op": "interestcontains",
            "value": ["a9014571b8", "5e824ac953"]
        }]
 }

这是带有 cmets 的 PHP 数组版本。 'match' 成员指的是 'conditions' 数组中的规则。段可以匹配任何条件、全部条件或不匹配任何条件。此示例只有一个条件,但可以将其他条件作为附加数组添加到“条件”数组中:

$segment_opts = array(
'match' => 'any', // or 'all' or 'none'
'conditions' => array (
    array(
        'condition_type' => 'Interests', // note capital I
        'field' => 'interests-31f7aec0ec', // ID of interest category
                                           // This ID is tricky: it is 
                                           // the string "interests-" + 
                                           // the ID of interest category
                                           // that you get from MailChimp 
                                           // API (31f7aec0ec)
        'op' => 'interestcontains', // or interestcontainsall, interestcontainsnone
        'value' => array (
            'a9014571b8',  // ID of interest in that category
            '5e824ac953' // ID of another interest in that category
        )
    )

  )
);

【讨论】:

  • 因此interests-31f7aec0ec 是类别的ID。那么这个条件是否匹配对该类别感兴趣的用户?您能否详细说明interestcontains 的含义? --- 最终,我只想向所有对interest_id "X" 感兴趣的用户发送一封电子邮件(我并不关心类别)
  • interestcontains 只是告诉 MG 使用 'value' 数组中包含的 ID 之一选择用户感兴趣的用户
  • 如何找到类别 ID?
【解决方案2】:

您也可以发送到已保存的片段。问题是segment_id 必须是int。我将此值作为 varchar 保存在 db 中,除非强制转换为 int,否则它将无法工作。

(我正在使用 \DrewM\MailChimp\MailChimp;)

$segment_id =  (int) $methodThatGetsMySegmentID;

$campaign = $MailChimp->post("campaigns", [
    'type' => 'regular',
    'recipients' => array(
        'list_id' => 'abc123yourListID',
        'segment_opts' => array(
            'saved_segment_id' => $segment_id,
        ),
    ),
    'settings' => array(
        'subject_line' => 'A New Article was Posted',
        'from_name' => 'From Name',
        'reply_to' => 'info@example.com',
        'title' => 'New Article Notification'
    )
]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-04
    • 2015-04-02
    • 1970-01-01
    • 2017-09-01
    • 2019-01-14
    • 2016-07-03
    • 2017-11-23
    • 2016-06-23
    相关资源
    最近更新 更多