Blog

2018.05.17

Tutorial: Use merge fields to pass users address to MailChimp via API without empty result. Problem solved

In categories: Tutorials, Website development

Recently I embarked on a journey to integrate MailChimp API with abandoned carts plugin. At first I thought that it should be a peace of cake since I saw their huge documentation, but I was mistaken and had to spend my whole afternoon digging google to understand why I am getting empty address field after everything else is imported. Just to be clear – I really like the new Mailchimp 3.0 API and they have done a beautiful job on the documentation but there still are some blind-spots.

From MailChimp documentation I found that when you are trying to add a new subscriber to one of your mailing lists you can use the “merge_fields” parameter to pass user related information like Name, Last name, Phone number and Address (this merge_fields cheat-sheet also came in handy). Passing all of these fields was quite easy except for Address field which didn’t register on MailChimp and every time returned an empty result (see screenshot below).

MailChimp API empty address fields

I tried multiple and various solutions to get this problem fixed (passing arrays, objects, strings etc.) until I turned to Google but it was really hard to find a good article that would help to fix this issue or explain how to pass Address field to MailChimp using merge_fields until I found a published email conversation that gave some explanation into how MailChimp is accepting Address field.

If you want to prevent Mailchimp returning empty Address field you have to pass 5 mandatory fields to it:

  • Address Line 1 (addr1)
  • City (city)
  • State (state)
  • Zip code (zip)
  • Country (country)

Unless one of these is left out, you will see empty column. Also I must add that none of these fields can be left blank even if you do not need or have some of those values replace it with “n/a” or similar.

Here is the working solution and end result of passing Address field to MailChimp via API:

After this I was finally able to get Address fields over to MailChimp. I hope this tutorial helps to save time and money for others in the same spot as I found myself one day :). Please comment below if you have some additional information to add.

Nauris Kolāts

Nauris is a freelance designer / developer who loves to dig into the UX as much as in the ground for fishing worms. And fishing is just one amongst the long list of his active lifestyle hobbies.

Other posts

Your thoughts

Thoughts

  1. Anja

    hello,
    Thank you for sharing your new found knowledge. I have the same question but for a ‘date’ field. Recently I added a ‘date’ field to my list. I imported a new list (including a column with dates) but the column ‘date’ in my list in MailChimp remained empty. Do you maybe have a suggestion to fix this problem?
    Thank you in advance!

    • Nauris Kolāts

      Hey Anja,

      Thanks for your question.
      If I understand you correctly, you are importing members into a list.
      From this MailChimp API page here: https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/ you can see that MailChimp says that date fields must be in a specific format.

      The date and time the subscribe confirmed their opt-in status in ISO 8601 format.

      So I would suggest you to double check the date format you have in your list prior to importing it to MailChimp.
      If the date field is not in the correct format, it will most probably be left blank.

      By the way you should check MailChimp API log file (under mailchimp.com/account/api/) after the import – there you could try to find some additional info about what is wrong with the import. It should be visible under “Last 24 hours of API calls“.

 

Latest work