Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mailchimp: how to set a merge var value for a specific list member

Tags:

var

mailchimp

What API in mailchimp should I use to set a merge var value for a specific list member?

If I'm adding a new list member, I can use lists/subscribe to set a merge var value for that new member. However, I do not see an API to change the value if the list member already exists.

The API lists/merge-var-set sets the value for all list members. And lists/merge-var-update sets attributes for the merge var.

What is the API for setting a specific value?

like image 409
Peri Hartman Avatar asked Aug 07 '15 22:08

Peri Hartman


2 Answers

In Mailchimp API v3 you can set a merge field value this way:

PUT {api_endpoint}/3.0/lists/{list_id}/members/{member_hash}

{
    "merge_fields": {
        "BIRTHDAY": "01/23"
    }
}

Where {member_hash} is md5 hash of member's email address.

You don't have to provide all merge fields. Mailchimp will update only those you've specified.

like image 137
Lukasz Wiktor Avatar answered Sep 21 '22 19:09

Lukasz Wiktor


In APIv2, you still use lists/subscribe, but you pass update_existing as well. This is considerably more intuitive in APIv3, which you should use if you can, since 2.0 is officially deprecated.

like image 37
TooMuchPete Avatar answered Sep 20 '22 19:09

TooMuchPete