Increasing your brand presence in a crowded market is of utmost importance to remaining relevant and having a competitive edge. Having the right knowledge about your client’s needs and desires can go a long way in shaping your decision making towards their specific requirements. There are various tools available that can help you in connecting with clients/customers in personal ways to foster rewarding and lasting relationships.
This article aims at showing you how to achieve Mailchimp Webhooks integration and set up custom events through Webhooks in the powerful email marketing platform, Mailchimp. A Webhook is a tool to collect information about your contacts. It can help alert your application when a campaign has finished sending emails or when it discovers an invalid email address. Webhooks integrations can also sync your client’s profile data with your database. Such integrations with Mailchimp can boost your marketing performance as you design a tailored approach to each customer.
Let’s see how this blog is structured for you:
What is Mailchimp?
Mailchimp is a marketing platform cum email marketing service that offers small and medium scale businesses access to industry-leading tools with which they can engage their customers through email marketing and automated workflows. In the field of marketing, email has shown a very high Return on Investment (ROI) and is still one of the most powerful marketing channels available. Mailchimp is a leader in this market segment as it provides not only email marketing services but integrates a suite of other services such as surveys and automated workflows for seamless interactions between businesses and customers to help create enduring brand appeal.
Mailchimp is owned by Rocket Science Group, an American company founded in 2001 by Ben Chestnut and Mark Armstrong along with Dan Kurzius. It is believed that in June 2014, Mailchimp was sending over 10 billion emails per month on behalf of its users.
The major focus of Mailchimp is to provide contact management, create beautifully designed email campaigns, and provide powerful data analysis.
What is Webhooks?
A Webhook sometimes called a web callback or HTTP Push API; is a way for an application to communicate with other applications. It takes the form of message passing, whereby an application sends a message or payload to another application, a predetermined event also occurs in the source application simultaneously. Since the nature of Webhook is based on events, it avoids the limitations of polling as the application that needs to be notified of a change does not need to constantly poll (ask) the source application whether that change has occurred. Also, check out Webhook to BigQuery integration.
With Webhooks, whenever the agreed-upon event happens, a message is sent to the consuming application via an HTTP request to the callback URL (the specified API endpoint for the consuming application). Webhooks are a resource-light way to implement event reaction between applications as they are much more efficient for both providers and consumers.
Hevo is a No-code Data Pipeline. It supports pre-built integration from Mailchimp along with other free data sources. It will automate your data flow in minutes. Its fault-tolerant architecture makes sure that your data is secure, reliable and consistent. With Hevo, data integrations become a cakewalk.
Get Started with Hevo for Free
Let’s look at some unbeatable features of Hevo:
- Fully Automated: Hevo can be set-up in a few minutes and requires zero maintenance and management.
- Scalability: Hevo is built to handle millions of records per minute without any latency.
- Secure: Hevo offers two-factor authentication and end-to-end encryption so that your data is safe and secure.
- Fault-Tolerant: Hevo is capable of detecting anomalies in the incoming data and informs you instantly. All the affected rows are kept aside for correction so that it doesn’t hamper your workflow.
- Real-Time: Hevo provides real-time data migration. So, your data is always ready for analysis.
- Live Support: Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
Are you ready to use Hevo? If yes, then give it a try by signing up for a 14-day free trial today.
Sign up here for a 14-Day Free Trial!
Mailchimp Webhooks Integration
In Mailchimp, Webhooks collects information about an audience (contacts) in a marketing campaign. It gathers information about an audience immediately, whenever any changes occur within that audience, be it when a campaign has finished sending emails or when a contact changes their email address. It is achieved by setting up a valid URL that accepts HTTP POST requests. Information received from the Webhook ranges from updates on subscriptions, e-commerce reporting for Facebook ads, landing pages activity, click reports in a campaign, opened email reports of recipients in a campaign, etc.
Note: To set up Webhooks in Mailchimp, you should have a Mailchimp account, an audience you would like to use a Webhook with, a callback URL for your application that can accept HTTP POST requests, an API key and server prefix. Follow these steps to achieve Mailchimp Webhooks integration:
1. Set up your Callback URL
To create a Webhook, the first thing you need is to have a callback URL that accepts HTTP POST requests. Mailchimp sends an HTTP POST request to the specified URL whenever a Webhook is triggered.
2. Create a New Webhook
A new Webhook can be set up in the Mailchimp web app or through the API. This section focuses on using the Mailchimp app for Mailchimp Webhook integration.
To create a Webhook, carry out the following steps:
- Log into your Mailchimp account and navigate to the Audience page.
- Select the audience you want to work with from the Current Audience dropdown.
- Click the Manage Audience dropdown button and select Settings.
- On the Settings page, click Webhooks.
- Click the Create New Webhook button.
- In the Callback URL field, add the URL of the integration or application where Webhook requests will be sent.
- Select the boxes next to each update type to choose the events that will trigger your Webhook, for example, Subscribes and Unsubscribes.
- Click Save to save your new Webhook.
3. Handling the Webhook Response in your Application
After setting up the Webhook, you need to handle the callback data in your application. The Webhook request is sent as application/x-www-form-urlencoded data, and the alert received by the triggered event is parsed as a JSON. Do note that the Webhook data codes are accessible through the Webhook URL that you set up. Examples of the JSON for the Subscribes and Unsubscribes events are shown below.
{
"type": "subscribe",
"fired_at": "2009-03-26 21:35:57",
"data": {
"id": "8a25ff1d98",
"list_id": "a6b5da1054",
"email": "api@mailchimp.com",
"email_type": "html",
"ip_opt": "10.20.10.30",
"ip_signup": "10.20.10.30"
"merges": {
"EMAIL": "api@mailchimp.com",
"FNAME": "Mailchimp",
"LNAME": "API",
"INTERESTS": "Group1,Group2"
}
}
}
{
"type": "unsubscribe",
"fired_at": "2009-03-26 21:40:57",
"data": {
"action": "unsub",
"reason": "manual",
"id": "8a25ff1d98",
"list_id": "a6b5da1054",
"email": "api+unsub@mailchimp.com",
"email_type": "html",
"ip_opt": "10.20.10.30",
"campaign_id": "cb398d21d2",
"merges": {
"EMAIL": "api+unsub@mailchimp.com",
"FNAME": "Mailchimp",
"LNAME": "API",
"INTERESTS": "Group1,Group2"
}
}
}
The next thing to do is to write the code that will handle the Webhook data on your server. Below is a sample code in JavaScript (NodeJS) using the Express web framework. The code uses a dummy stand-in customerDB with functions to interact with a database using Subscribes and Unsubscribes events.
const express = require("express");
const bodyParser = require("body-parser");
// this is a stand-in for the code you'd use to write to your own database
const customerDB = require("customerDB");
const app = express();
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }));
app.post("/", (req, res) => {
const { type, data } = req.body;
if (type === "subscribe") {
customerDB.subscribeUser(data);
} else if (type === "unsubscribe") {
customerDB.unsubscribeUser(data.id);
}
});
app.listen(port, () =>
console.log(`Listening at http://localhost:3000`)
);
4. Test your Webhook
If you have completed an appropriate code set-up, you can test your Webhook in the Mailchimp app. The steps, as stated below, is used to test for a subscription event.
- Go to the Audience page and select the audience you would like to add a test member.
- In the Add Contacts dropdown, select Add a Subscriber.
- Fill in the input fields with information for your test email account.
- Check the checkbox for “This person gave me permission to email them”, if you would like to skip the step of confirming the subscription manually.
- Hit Subscribe.
- Your server should receive the Webhook request, and your database should be updated accordingly.
For further reading, visit the official documentation page for Mailchimp synchronization.
Conclusion
In this article, you have gone through the process of setting up Mailchimp Webhooks integration to receive alerts when an event takes place. It was done using examples of Subscribes and Unsubscribes events. These custom alerts, when set up for an audience, is useful to know your contact’s subscription status, therefore helping you in drawing up appropriate strategies to build sustainable customer relationships. There are alternative methods for setting up Mailchimp Webhooks integration, such as using Hevo Data.
Visit our Website to Explore Hevo
Hevo is a No-code data pipeline that supports pre-built integration from Mailchimp along with other free data sources and can simplify the process of managing your Mailchimp Webhooks integration. You don’t need to write custom code but will be able to access all the benefits associated with Webhooks through a point and click interface.
Give Hevo a try by and Sign Up for a 14-day free trial today.
Share your experience of Mailchimp Webhooks integration in the comment section below.