1.0.2 • Published 6 years ago

mailigen v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Mailigen JS

This simple library gives you the ability to add email to your newsletter lists on Mailigen.

Installation

yarn add mailigen

Environment Variables

To use this library, you need to set 2 API keys as environment variables.

  • MAILIGEN_LIST
    • Set this to your List ID. See below for finding your list ID.
  • MAILIGEN_API_KEY
    • Your API key

Finding your List ID

To find your List ID:

  1. View all of your lists
  2. Select the list you want to use
  3. On the list page, click "List Actions" -> "Web Signup Forms"
  4. Web Signup forms
  5. Click the link next to "Your hosted web signup form link"
  6. Copy the id URL parameter on the link that opens. This is your List ID for use with the API

Using Mailigen JS

The subscribe method uses 3 arguments:

  1. The email to add
  2. Any merge variable you want to use (defaults to {})
  3. Any extra options to pass to the listSubscribe method (defaults to {})

Here is an example:

import { subscribe } from 'mailigen';

async function addEmail(email, firstName) {
  const response = await subscribe(email, { 'FNAME': firstName }, { 
    send_welcome: true
  });
}