react-mailchimp-subscribe icon indicating copy to clipboard operation
react-mailchimp-subscribe copied to clipboard

Can we add people to groups or tag them on submission?

Open ConnorVO opened this issue 4 years ago • 6 comments
trafficstars

Tried adding a hidden input like Mailchimp suggests, but that doesn't seem to work.

ConnorVO avatar Feb 01 '21 07:02 ConnorVO

You can do this already using a custom form, just add the group information to the data you are sending. For example:

        onSubmit={e => {
          e.preventDefault();
          this.props.onSubmit({
            EMAIL: this.state.email,
           'group[8291][1]': '1'
          });
        }}

MichaelMarner avatar Feb 15 '21 11:02 MichaelMarner

is there a way to do this with tags? I tried

onValidated={(formData) =>
                    subscribe({
                      ...formData,
                      tags: ['MY TAG NAME'],
                    })
                  }

the request was posted succesfully but the tag was not added

thisisthais avatar May 14 '21 18:05 thisisthais

If anyone is wondering, here is the doc that describes how to automatically add customers to groups: https://mailchimp.com/help/automatically-add-subscribers-to-a-group-at-signup/

is there a way to do this with tags? I tried

onValidated={(formData) =>
                    subscribe({
                      ...formData,
                      tags: ['MY TAG NAME'],
                    })
                  }

the request was posted succesfully but the tag was not added

I don't think this can be done in the same way as the groups thing, but you can checkout their tags api

smac89 avatar Sep 02 '21 16:09 smac89

I managed to solve adding tags with <MailSubscribeForm status={ status } message={ message } onValidated={(formData) => {subscribe({...formData, "tags": "SOME TAG NUMBER"})}} />

liordavid avatar Jan 25 '23 10:01 liordavid

@liordavid Where do you find the tag number?

tim-basic avatar Feb 11 '23 01:02 tim-basic

I managed to get tags working like this within a custom form:

  const handleSubmit = (e) => {
    email &&
      firstName &&
      lastName &&
      rsvpFor &&
      numAttending &&
      email.indexOf('@') > -1 &&
      onValidated({
        'group[54061][1]': '1',
        EMAIL: email,
        MERGE1: firstName,
        MERGE2: lastName,
        MERGE9: rsvpFor,
        MERGE7: numAttending,
        tags: '10511025,10511021',
      });
  };

I got the tag numbers by making an embedded form with the tags and then looking at the tag input in the generated code.

tim-basic avatar Feb 11 '23 01:02 tim-basic