mailigen
v1.0.2
Published
A JS library for using the Mailigen API
Downloads
5
Readme
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:
- View all of your lists
- Select the list you want to use
- On the list page, click "List Actions" -> "Web Signup Forms"
- Click the link next to "Your hosted web signup form link"
- 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:
- The email to add
- Any merge variable you want to use (defaults to
{}
) - 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
});
}