17

With the MailChimp API, to add a member to a list with a specific interest group, you need both that list's ID and the interest group's ID.

To get both those IDs, you can either query the API for them, or in the case of the list ID you can find it in the form code that the MailChimp interface outputs. The interest group ID can not be found in the same way: the form code simply users integer IDs to reference the interest groups, which are not accepted by the API.

My question: is there any way to get the interest group IDs other than querying the API first? i.e. somewhere in the MailChimp interface?

Context: I'm building a simple add-on to a Wordpress website that includes a MailChimp signup form with interest groups. Parameters are set in the website admin including API key and list ID. If possible, I'd like to avoid having to build in a query mechanism to get, list and select the interest groups and rather just have the administrator enter the IDs.

ekad
  • 14,436
  • 26
  • 44
  • 46
Tim Malone
  • 3,364
  • 5
  • 37
  • 50

7 Answers7

48

You can use the Playgrounds in the Mailchimp Developer site located at developer.mailchimp.com

The Playground is a UI into the API and you can drill down using the Subresources into -> lists -> interest-categories -> interests.

Then choose the Response view and it will show the payload of the response that contains the id's you are looking for.

sonic_ninja
  • 728
  • 7
  • 8
  • 800 views and only 1 upvote? what is going on guys? btw @jneptune -> you should probably mention https://developer.mailchimp.com/ for access to playground, so not everyone has to google it – Toskan Mar 08 '17 at 14:54
  • 7
    Using the API Playground only displays a certain amount of Interests though, I believe only the first 10. So if you have more than that you'll need to find a different solution. – CJdriver Jun 27 '17 at 14:45
  • 6
    This is totally insane. Why doesn't Mailchimp just *display* the ID that we obviously all need. I really, really, really can't stand lazy developers. – AJB Mar 22 '18 at 20:29
  • Given the nature and scope of MailChimp I wouldn't go as far as to call their developers lazy :-) However, it would be really, really helpful if the Group ID were available via the control panel rather than having to query the API for it. – MrCarrot Jun 15 '18 at 11:35
  • 2
    I've only just found this. But the playground now has a notice that they are retiring it in 3 days time! What a pity. – ChrisFox Nov 06 '20 at 17:12
  • 1
    I spoke with Mailchimp and the playground has been sun-setted. – Adam Gonzales Nov 11 '20 at 16:07
  • 1
    This answer is no longer working as the playground does not exist any longer. – INT Aug 13 '21 at 13:37
  • Yep, wonderful Mailchimp. That has no sandbox or development mode, but does have their own streaming shows!? Someone suggest a new email list provider that I can migrate to! – evolross Aug 18 '21 at 22:31
  • So how do we do this now? I'm not trying to do something fancy - I already have a form on my website (using MC4WP) and simply need to add a newly created interest group option to it. Using MC4WP's "Renew Lists" did not change the form, so I need that ID to add the markup myself. – OsakaWebbie Jan 22 '22 at 01:26
  • 1
    Never mind - I found a way. For any who might have the same question, in MC4WP's MailChimp section, click the list name and it will fetch and show all the merge fields and interest groups, with all the IDs. – OsakaWebbie Jan 22 '22 at 02:06
8

I am using V3 API and you can use Playground to get group id (Mûhámmàd Yäsår K group name doesn't work for me)

Playground > List > [Your list] > interest-categories > interests > [Your group]-> You'll see payload with field id

Now that you have the group id, you can play with creating members: Playground > List > [Your list] > members > Click Create members

Here's the sample payload:

{
    "email_address": "user@mail.com",
    "status": "subscribed",
    "merge_fields": {
        "EMAIL": "user@mail.com",
        "FNAME": "Firstname",
        "LNAME": "Lastname",
        "POST_CODE": "",
        "ADDRESS": "",
        "PHONE": ""
    },
    "interests": {
        "733ba3180d": true
    }
}

Note: interests is not inside merge_fields

Hope this help.

S.I.
  • 3,250
  • 12
  • 48
  • 77
Kent V
  • 545
  • 5
  • 16
1

As far as I know, the only way to find the interest or interest-category IDs are through the API itself.

TooMuchPete
  • 4,583
  • 2
  • 17
  • 21
1

As mentioned above you can use the Playgrounds in the Mailchimp Developer website (developer.mailchimp.com) also you can sort your group's order so you can retrieve all the ids you need instead of relying on the API call or being limited to the first 10.

0

The group IDs can also be found in the embed coding form page, but only if the groups aren't hidden.

Ollie
  • 9
  • 1
  • The group IDs from the API are different than the embed code. I just tried this and the format is different and the values are not the same as what the API returns for the group id. – evolross Aug 19 '21 at 18:13
0

What worked for me was using playground: https://us1.api.mailchimp.com/playground/

And then to use it, what worked for me was exactly like these:

$json = json_encode([
    'email_address' => $data['email'],
    'status'        => "subscribed", // "subscribed","unsubscribed","cleaned","pending"
    //'tags'  => array('es'),
    'merge_fields'      => [
        'FNAME'         => $data['name'],
        'USER'          => $data['user'],
        'COUNTRY'       => $data['country'],
        'BIRTHDATE'     => $data['birthdate'],
        'SUBSCRIP'      => $subsription
    ],
    "interests" => array(
        'PLACE_HERE_THE_ID' => true
    )
]);

Hope this helps :)

Dani G.
  • 577
  • 8
  • 21
-2

You can use either interest group id or its name for this(Hope you are using MaiChimp API v3). You can find it the MailChimp interface itself.

You need to use name instead of id as the parameters.

Please let me know if have any issue with using it. :)

Mûhámmàd Yäsår K
  • 1,492
  • 11
  • 24