Taking Advantage Of Mailchimp Web Hooks

mailchimp webhooks example

This article will guide you on how we can take the advantage of the Mailchimp web hooks in order to keep our database synchronized with mailchimp data. Actually in our database we stored the data from mailchimp user profile such as emailname and subscription status (i.e subscribed or unsubscribed).

Now to keep our database column updated there are two ways:

  1. Fire an mailchimp API call whenever the user signs in or update data once in day. But its way too costly. What if the profile data of the user updates occasionally ?
  2. Take advantage of the mailchimp web hooks which will only come into picture when data is updated at mailchimp.

Any intelligent programmer would always go with the second option. That a nice decision!

How to add web hooks?

Go to list tab
Select web hook option from settings
Create new web hook button
Add callback URL and option selection

Let’s take an example of Email changed web hook.

Suppose the user changes the email on the mailchimp. This will fire your configured callback URL you will get following parameters.

We can figure out the type of the callback from params[‘type’].

It will be upemail for email change, subscribed when a user subscribes for a list, unsubscribed when a user unsubscribes from the list. etc.

In case of the email change callback we get the following things

So on the basis of the parameters that we get in callback we synchronise the database!

So just follow the above steps and you re good to go !!!

Thanks for reading. If you liked it, press the heart button 🙂

Click here for more details…

At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.

We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.

Consulting is free – let us help you grow!

Related posts

Rotate Log Files in Rails Application with LogRotate in Ubuntu

by Harmisha Prajapati
6 years ago

How to extract text from an image in Python

by BoTree Technologies
3 years ago

Top 8 Reasons Java Development Remains Relevant in 2023

by Shardul Bhatt
4 years ago
Exit mobile version