The production-ready Medusa DTC Starter is outRead the announcement
E

Ecomail

Ecomail integration plugin for Medusa v2 - email marketing and transaction tracking

npm install medusa-plugin-ecomail
Built by
Version
1.1.0
Last updated
11 months ago
Monthly downloads
Loading downloads

medusa-plugin-ecomail

Ecomail integration plugin for Medusa v2 - email marketing and transaction tracking.

Features

  • ๐Ÿ“ง Subscriber Management - Add, update, and manage Ecomail subscribers
  • ๐Ÿ›’ E-commerce Tracking - Automatically track order transactions in Ecomail
  • ๐ŸŽฏ Smart Subscription - Intelligent handling of new subscribers, updates, and resubscriptions
  • ๐ŸŽจ Admin UI - Built-in admin panel for testing and managing subscribers
  • ๐Ÿ”„ Auto-sync - Automatic synchronization of customer data with Ecomail lists

Compatibility

This plugin is compatible with Medusa v2 (>= 2.11.2).

Installation

Configuration

Basic Configuration (Default Mode)

Add the plugin to your :

Default Behavior: All customers are automatically synced to Ecomail when they place an order.

GDPR-Compliant Configuration

For GDPR compliance, enable explicit consent requirement:

GDPR Behavior: Only customers who explicitly consent are synced to Ecomail.

Environment Variables

Add these to your file:

Configuration Options

OptionTypeRequiredDefaultDescription
stringYes-Your Ecomail list ID
stringYes-Your Ecomail API token
stringNoYour shop domain for transaction tracking
booleanNoRequire explicit consent before syncing customers
stringNoMetadata key to check for consent

Automatic Syncing

The plugin automatically syncs customers to Ecomail when orders are placed. No additional code is required!

How It Works

  1. Customer places an order โ†’ event fires
  2. Plugin checks consent (if is enabled)
  3. Syncs customer data to Ecomail list
  4. Tracks transaction for e-commerce analytics

Default Mode ()

All customers are automatically synced to Ecomail when they place an order. No consent checking is performed.

GDPR Mode ()

Only customers who explicitly consent are synced. The plugin checks for consent in order or customer metadata.

How to pass consent from your storefront:

When completing checkout, include the consent flag in the order metadata:

The plugin checks for consent in this order:

  1. Order metadata ()
  2. Customer metadata ()

If consent is , the customer is synced. If or missing (in GDPR mode), the sync is skipped.

You can use a different metadata key for consent:

Then pass it from your storefront:

Usage

In Your Code

Import and use the Ecomail service in your custom modules, subscribers, or workflows:

Admin Panel

The plugin adds an Ecomail settings page to your Medusa admin panel where you can:

  • Test subscriber operations (Check, Add, Update, Smart Add)
  • View subscriber details
  • Verify plugin configuration

Access it at: Settings โ†’ Ecomail

API Reference

EcomailService Methods

Adds a new subscriber to the Ecomail list.

Parameters:

  • (required) - Subscriber email
  • - First name
  • - Last name
  • - City
  • - Country code
  • - Postal code
  • - Company name
  • - Street address
  • - Phone number

Retrieves an existing subscriber from the list.

Updates an existing subscriber's data.

Smart method that:

  • Adds subscriber if they don't exist
  • Updates subscriber if they exist and are subscribed
  • Resubscribes if they exist but are unsubscribed

Tracks an e-commerce transaction in Ecomail with order details and items.

Custom Integration Examples

Using the Service Directly

While the plugin automatically syncs on order placement, you can also use the service directly for custom scenarios:

Manual Sync from API Route

TypeScript Types

Testing

Default Mode (sync everyone):

  1. Configure plugin without or set it to
  2. Place a test order
  3. Verify customer appears in Ecomail list
  4. Verify transaction is tracked

GDPR Mode (require consent):

  1. Configure plugin with
  2. Place order WITH consent ()
    • Customer should be synced โœ“
  3. Place order WITHOUT consent ()
    • Customer should NOT be synced โœ“
  4. Place order with NO metadata
    • Customer should NOT be synced โœ“

Testing via Admin Panel

The plugin includes an admin panel (Settings โ†’ Ecomail) where you can:

  • Test adding subscribers manually
  • Check if a subscriber exists
  • Update subscriber information
  • Verify your Ecomail connection

Error Handling

The plugin is designed to be resilient:

  • Ecomail sync failures do not break the order flow
  • All errors are logged for debugging
  • Orders complete successfully even if Ecomail is unavailable

Development

Resources

License

MIT

Author

Gramino


Made with โค๏ธ for the Medusa community