Do you know how to check if someone is already subscribed on the mailchimp list?
In the example above I check the Wix database to see if the email address is already subscribed. If they are then I do not submit to MailChimp again. In my example, the only way for someone to subscribe to the MailChimp list is through the website, so I do not need to check the MailChimp list to see if the email address is already subscribed.
That being said, you should be able to send a GET request to MailChimp, the response should tell you if they’re already subscribed.
Hey Toby. Question… I get the point of the code, but where are you collecting the information from to go into Mailchimp? Are you using Wix Subscribe?
Oh, I re-read this… you’re creating a custom form.
Works like a charm Toby, Thank you
Thank you so much for this Toby! Exactly what I needed! Also thanks for the tip with Postman - I needed it to sort out why my API requests weren’t working (this article also came super handy: Intro to MailChimp API 3.0: Adding Members to a Mailing List and testing with Postman | by Denise Ortega | Medium )
One thing maybe that can help others - if you have a boolean in your wix database make sure to have a workaround for changing that to a string (maybe other type works too) before making the api call. - I guess just like Toby did with subscribed.
Hello folks,
As Toby provided a code in the begining of this forum, I added backend code and the page code.
Mine is a custom form I created myself.
Once the submit button is pressed, user input is logged into my database called database5.
I also have couple of merge fields that I added.
I made few changes from the initial code to suite my needs.
But, this code does n’t send any info to my mailchimp account. Can someone peer review my code here please.
export function database5_afterInsert() {
var data = {
“email_address”:$w(“#input2”).value,
“merge_fields”: {
“FNAME”:$w(“#input1”).value,
//“LNAME”:item.lName
“PHONE”:$w(“#input3”).value,
“MMERGE6”: customerObject.field1, //custom merge field
“MMERGE7”: customerObject.field2, //custom merge field
},
“status”:“subscribed”
};
data = JSON.stringify(data, ‘\t’);
sendToMailChimp(data);
}
Hi, I got it fixed. customerobject.field2 was returning empty string. When I updated with some default string, it worked.
The articles in this forum have been very useful. specially postman and tobys code.
Thanks,
Now I am able to send contact info to the mailchimp from wix userform.
But, what I want to do is, if the user resubmits the input with differnt info, the mailchip contact is not updated! Postman says that it cannot add the info with same email address.
Is there any way to overwrite the info if email address is already existing in mailchimp?