Adding custom merge tags to Mailchimp API 3.0

I went around everywhere but can't find hints to add custom merge tags via api v3.0. The documentation seems very poor and mysterious.

I saw that in the previous version this can be done using the method listMergeVarAdd().

I want to add dynamic merge_tags.

How to add custom merge_tagsvia mailchimp api 3.0 for use in a custom subscription form?

+4
source share
2 answers

v3.0 RESTful, POST /3.0/lists/{list_id}/merge-fields. , , .

+3

, , - .

VATPS Wrapper https://github.com/vatps/mailchimp-rest-api

$api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-usx";      
$mc = new MailChimp();
$mc->setApiKey($api_key);

    // Create Custom Merge Tags - Example           
    $result = $mc->post('/lists/{list-id}/merge-fields', array(
                    "tag" => "CUSTOM_SST",
                    "required" => false, // or true to set is as required 
                    "name" => "Custom Field",
                    "type" => "text", // text, number, address, phone, email, date, url, imageurl, radio, dropdown, checkboxes, birthday, zip
                    "default_value" => "", // anything
                    "public" => true, // or false to set it as not 
                    "display_order" => 2,
                    "help_text" => "I try to help you!"
                ));
    print_r($result);

    // Check If Merge Tags Already Exists - Example
    $result = $mc->get('/lists/{list_id}/merge-fields');
    print_r($result);
+1

Source: https://habr.com/ru/post/1608521/


All Articles