UNPKG

@vagalumedigital/gatsby-plugin-mailchimp-api

Version:

A plugin written to use Mailchimp API v3 to add/update users subscribed on a list

61 lines (45 loc) 1.78 kB
# UNDER DEVELOPMENT DO NOT USE ### Intro This is a plugin developed to manage your contacts on your audience. This plugins add a user to your audience or update it if it exists already. We have some plans to expand this plugin and fully integrate with Mailchimp API, allowing you to use a full featured mailchimp integration in your Gatsby sites. Feel free to send suggestions :blush: This plugin was based on [Benjamin Hoffman's gatsby-plugin-mailchimp](https://github.com/benjaminhoffman/gatsby-plugin-mailchimp) and [Rohov Dmytro's gatsby-source-mailchimp](https://github.com/RohovDmytro/gatsby-source-mailchimp). I recommend you to check those plugins, maybe they will help you too. ### Installation ``` yarn add @vagalumedigital/gatsby-plugin-mailchimp-api ``` ### Usage `gatsby-config.js` ```javascript [ { resolve: `gatsby-plugin-mailchimp-api`, options: { id: '<ID-OF-YOUR-MC-LIST>', // string; ID of your mailchimp list found on your list settings key: '<MC-API-KEY>', // string; You can find your API key in account settings of your mailchimp account. } } ]; ``` Import the module on your code ```javascript import { addToMailchimp } from '@vagalumedigital/gatsby-plugin-mailchimp-api' ``` Then add the following code to your form submit: ```javascript addToMailchimp( // email 'email@example.com', // merge fields { 'FNAME': 'John', 'LNAME': 'Doe', }, // interests. The ID of the interest is the key of the object. Remember, it's a object not a array! { ff8fc8c005: false }, ).then(data => console.log(data)); ``` If you want to get the interests of the list you're subscribing into, you can call: ```javascript import { getInterests } from '@vagalumedigital/gatsby-plugin-mailchimp-api' getInterests() ```