Find it on GitHub: /edgee-cloud/mailchimp-subscribe-component

This component provides a simple way to add new subscribers to Mailchimp directly from the edge. The WebAssembly component allows you to collect email addresses through an HTTP endpoint and automatically add them to your Mailchimp audience.

Features

  • Simple Email Collection: Add subscribers via HTTP POST requests
  • Edge Performance: Processes subscription requests directly at the edge
  • Configurable Endpoint: Set custom paths for your subscription endpoint
  • Mailchimp Integration: Direct integration with Mailchimp’s API
  • WebAssembly Performance: Fast, secure execution in a sandboxed environment

Getting Started

To integrate Mailchimp with your project:

  1. Open the Edgee console and navigate to your project’s Components.
  2. Select “Add a component” and choose edgee/mailchimp-subscribe from the list of available edge functions.
  3. Configure the following settings:
    • API Key: Your Mailchimp API key
    • Data Center: Your Mailchimp data center (e.g., “us1”, “us2”)
    • List ID: The ID of your Mailchimp audience/list
    • Path Configuration: Set the subscription endpoint path (e.g., /subscribe)
  4. Click Save to activate the subscription endpoint.

Usage

Once configured, you can add subscribers by sending POST requests to your configured endpoint:

await fetch('/subscribe', {
  method: 'POST',
  body: JSON.stringify({
    "email_address": "user@example.com"
  })
});

Request Format

{
  "email_address": "user@example.com"
}

Response

The component will return a response indicating whether the subscription was successful or if there was an error.

Use Cases

  1. Newsletter Signup: Simple email collection for newsletters
  2. Lead Generation: Capture potential customer emails
  3. Event Registration: Collect attendee information
  4. Product Updates: Build audiences for product announcements
  5. Content Gating: Require email signup for premium content

Error Handling

The edge function provides comprehensive error handling:

  • 400 Bad Request: Invalid request format or missing required fields
  • 401 Unauthorized: Invalid API key or authentication failure
  • 404 Not Found: List or subscriber not found
  • 409 Conflict: Subscriber already exists
  • 500 Internal Server Error: Mailchimp API error

Make sure to comply with GDPR and other privacy regulations when collecting email addresses. Always obtain proper consent before adding users to your mailing lists.