Home » PHP17 October 2017

MailChimp API v3.0 – Add Store to List, Add Product to Store, Add Order to Campaign

This article shows how you can use MailChimp API v3.0 with PHP and CURL to add ecommerce data to your MailChimp campaign. When purchases happen in your shop then you can add your purchase order data to MailChimp to track purchases from your MailChimp Campaign. A MailChimp campaign is associated to any particular MailChimp list.

To add order data into MailChimp you need to follow the below steps sequentially:

1) First add store to mailchimp list.
2) Then add products to store in mailchimp.
3) And then we can add orders to mailchimp campaign.

If you try to add order data into mailchimp campaign without adding products to mailchimp store then you get error. Similarly, you need to first add store to mailchimp list. Only then you can add products to that store.

Developer Documentation on Get Started with the E-Commerce API

Add Store to Mailchimp List

You need an API Key to add store to a mailchimp list. This article shows how you can get an API key on MailChimp: About API Keys.

The API Key is in the format as xxxxxxxxxxxxxxxxxx-us13.

Here,
xxxxxxxxxxxxxxxxxx = some random number and letter
us13 = server name, it can be us2, us3, us10, etc.

The other necessary thing is the list ID to which we will be adding our store. Below is the procedure to get List ID in MailChimp:

Getting your list ID

The list ID is not the numeric ID of the list. It is a combination of random letter and number.

You will get the list ID from ‘List name and defaults’ page.

– Create a list on your MailChimp account
– Click on that list
– Click on the ‘Settings’ menu
– A dropdown with sub-menus is displayed
– Click on the ‘List name and defaults’ sub-menu.
– On that page, on the right side, you will find the list ID highlighted in red/maroon color.

This link can be helpful to get into the ‘List name and defaults’ page: Find your List ID

You need to post the store data to this URL: https://'.MAILCHIMP-SERVER.'api.mailchimp.com/3.0/ecommerce/stores

Here, MAILCHIMP-SERVER = Some random number and letter. It can be us2, us3, us10, etc.

Here is the code to add store to mailchimp list:

Add Product to Store in MailChimp

You need to post the store data to this URL: https://'.MAILCHIMP-SERVER.'api.mailchimp.com/3.0/ecommerce/stores/1/products/

Here, MAILCHIMP-SERVER = Some random number and letter. It can be us2, us3, us10, etc.

Here is the code to add product to mailchimp store:

Here is the Reference Doc for Products

Add Order data to MailChimp Campaign

You need to post the store data to this URL: https://'.MAILCHIMP-SERVER.'api.mailchimp.com/3.0/ecommerce/stores/1/orders/

Here, MAILCHIMP-SERVER = Some random number and letter. It can be us2, us3, us10, etc.

Here is the code to add order to mailchimp campaign:

Here is the Reference Doc for Orders

Hope this helps. Thanks.

PHP

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed