listSegmentCreate()

New segment is created for a given single list. You may add multiple rules to filter out contacts in your list by merge field values. Provide match type to match all or any of given rules.

listSegmentCreate(string $list, string $title, string $match, array $filter, boolean $auto_update) : string
Input parameters
  • list - list ID that the segment will be based on
  • title - name of the segment
  • match - match type (AND, OR) to be used when chaining together multiple filter rules
  • filter - list (array) of rules to filter out contacts. Every rule is an array consisting of:
    • field - merge field tag
    • condition - condition name (is, not, isany, isoneof, notoneof, contains, notcontain, starts, ends, greater, less)
    • value - value that will be used for filtering.
  • auto_update - whether segment is static or updated automatically every time information about subscriber changes (true, false) (optional). Default value is false.
You may enter multiple values separated by semicolon ";" when using condition isoneof or notoneof.

Information obtained
  • ID of the new segment

Examples

mgapi_listSegmentCreate.php
<?php
/**
 * This Example shows how to listSegmentCreate using the MGAPI.php class and do some basic error checking.
 */
require_once 'inc/MGAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
 
$api = new MGAPI($apikey);
 
$list = $listId;
$title = 'Test Segment';
$match = 'all'; //any, or, all, and
$filter = array(
    array(
        'field' => 'merge0',
        'condition' => 'ends', //is, not, isany, contains, notcontain, starts, ends, greater, less
        'value' => '@gmail.com',
    ),
    //...
    array(
        'field' => 'confirm_time',
        'condition' => 'greater',
        'value' => '2013-01-01',
    ),
);
$auto_update = false;

 
$retval = $api->listSegmentCreate($list, $title, $match, $filter, $auto_update);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load listSegmentCreate()!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "New Segment ID:" . $retval . "\n";
}

© 2010-2018 Mailigen. All rights reserved.