benjaminhoffman / gatsby-plugin-mailchimp

A simple, lightweight Gatsby plugin to subscribe new email addresses to your Mailchimp list
https://www.npmjs.com/package/gatsby-plugin-mailchimp
MIT License
138 stars 31 forks source link

Can this be used with Mailchimp's Contact Form / Inbox? #92

Open modulareverything opened 3 years ago

modulareverything commented 3 years ago

They give a similar endpoint for their contact forms so I'm wondering if this is possible using this plugin?

modulareverything commented 3 years ago

Thought I'd update this as I'm trying things out.

I tried adding the contact form endpoint in place of the default mailing list endpoint, like this (where my_user_id and contact_form_id are the proper ids from the endpoint):

    addToMailchimp(
      data.contactEmail,
      {
        NAME: data.contactName,
        SUBJECT: data.contactSubject,
        MESSAGE: data.contactMessage,
      },
      'https://us1.list-manage.com/contact-form?u=my_user_id&form_id=contact_form_id'
    );

This doesn't work and gives me some errors I'm unsure about:

Uncaught (in promise) Error: Timeout
    at eval (index.js:63)

and also a "CORB" error (never heard of this):

index.js:94 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://us1.list-manage.com/contact-form?u=my_user_id&form_id=contact_form_id&EMAIL=hey%40chrish.design&NAME=Chrish&SUBJECT=Testing%20Subject&MESSAGE=My%20message%20would%20go%20here&c=__jp2 with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
modulareverything commented 3 years ago

I tried adding this into the index.js file of this plugin to see if contact-form needed to be contact-form-json the same as post does...

    if(endpoint.includes('contact-form')) {
        endpoint = endpoint.replace(/\/contact-form/g, '/contact-form-json');
    } else {
        endpoint = endpoint.replace(/\/post/g, '/post-json');
    }

but nah, no joy here either!

CaptainHaider commented 3 years ago

did you find any solution?

LucyMac commented 2 years ago

I was also hoping to use this plugin with a contact form but I'm getting the CORB error. Does anyone have any tips / alternatives to suggest?

Thanks 🙏🏼