Automatically Subscribing Gumroad Customers to MailChimp

A method for automatically subscribing new Gumroad customers to a MailChimp list. It’s not pretty, it’s not super-simple, but it works. Warning: moving parts (your own server, nginx) involved.

I was looking for a way to automagically import new Gumroad customers into my MailChimp subscription lists. The usual inter-service integration suspects at Zapier and IFFFT turned up nothing; a Google search returned only those suffering from the same problem.

I decided I’d whip something up myself.

Normally, solving this problem would be pretty trivial – write a server-side script in a language of choice and point Gumroad’s convenient ping alert at it. When a new customer makes a purchase, Gumroad makes a POST request to the script, which extracts the email and other details, then make a corresponding call to MailChimp’s API to add that user as a subscriber to my list.

Of course, for some reason I decided to make it hard on myself and see if I could solve this problem using only the stock nginx running on my server, without using any server-side scripting. This effectively means that my call to the MailChimp API is really just a proxied call from Gumroad’s own ping request – kinda neat, if a bit unnecessary.

To cut to the chase, here’s the nginx configuration I used:

server {
  ### ...standard server configuration... ###


  location /ping/ {
    proxy_set_header Content-Length 0;
    proxy_set_header X-Request-Body $args&$request_body;
    proxy_pass_request_body off;

  location /convert-to-get/ {

  location /mailchimp/ {
    proxy_set_header Host $;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_body apikey=$arg_mc_api_key&id=$arg_mc_list_id&email[email]=$arg_email&double_optin=0;
    proxy_pass https://$;

(If you’re wondering about the resolver directive, it’s required for the dynamic proxy_pass call using the $arg_mc_dc variable later in the piece. Here for more.)

After adding this to the nginx.conf or similar, Gumroad needs to be pointed to it under the “Developer” tab on Gumroad’s settings page, with a URL like the following:<MAILCHIMP_API_KEY>&mc_list_id=<MAILCHIMP_LIST_ID>&mc_dc=<MAILCHIMP_API_DATACENTER>

As you can see, it’s all a bit hairy and slightly over-the-top for a simple task better handled by a short server side script. The nginx configuration proxies the incoming request from Gumroad three times, extracting the POST data sent from Gumroad and converting to GET data so that we can access and modify it in the subsequent request handlers, before finally proxying off to the MailChimp API in the expected format. The MailChimp API key, list ID and API datacenter (all required for MailChimp API calls – see here – are all passed in the initial request from Gumroad, so there’s no need to add them to the server configuration (although you may very well want to instead of passing it from Gumroad).

Certainly open to improvements and suggestions over this very quick and dirty solution, so if you have them, please get in touch via email or Twitter!

Heads Up: Since writing this, the good folks at Zapier and Gumroad have released an integration which allows you to do this far less painfully. Check it out →