Can I submit a new subscriber to Campaign Monitor with an AJAX request?

485 Views Asked by At

I have a form on a Shopify site that has a name and email field as well as other fields. The form submits to a Shopify url. Before it submits, I want to send the name and email fields to a Campaign Monitor list.

Is this possible to do in JavaScript? Is there some way to use an AJAX request to add a subscriber to Campaign Monitor?

  • I cannot find a Campaign Monitor JavaScript API.
  • I have tried embedding a form generated by Campaign Monitor, and submitting it using jQuery.ajax(), but that encountered a CORS error indicating that Campaign Monitor will not accept the request.
  • I cannot submit the embedded form directly in a way that will reload the page as I need to also submit the other form to Shopify.
1

There are 1 best solutions below

2
On

I would create a middleware accepting CORS requests that will receive subscriber data via AJAX from your Shopify website, process/validate it and then submit it to Campaign Monitor.

You can also avoid CORS by creating a custom app and adding a proxy extension pointing to a specific path on your server. Then you can send AJAX requests to a path within the Shopify e.g. /tools/campaign-monitor/subscribe which will actually be proxied to your server script that will send subscriber to Campaign Monitor.