Address in merge_vars

Mar 8, 2011 at 8:11 PM

I've created a simple form that sends the data to a MailChimp account, but I can't seem to get the address fields to capture.  My code looks something like this:

        listSubscribeInput input = new listSubscribeInput();
        input.api_Validate = true;
        input.api_AccessType = EnumValues.AccessType.Serial;
        input.api_OutputType = EnumValues.OutputType.JSON;
        input.parms.apikey = MCAPISettings.default_apikey; = "mylistid";
        input.parms.email_address = "";
        input.parms.double_optin = false;
        Dictionary<string, object> address = new Dictionary<string, object>();

        address.Add("addr1", "55 Main St.");
        address.Add("city", "San Diego");
        address.Add("state", "CA");
        address.Add("zip", "92102");

        input.parms.merge_vars.Add("EMAIL", "");
        input.parms.merge_vars.Add("FNAME", "Firstname");
        input.parms.merge_vars.Add("LNAME", "Lastname");
        input.parms.merge_vars.Add("homeadr", address);

        listSubscribe cmd = new listSubscribe(input);
        listSubscribeOutput output = cmd.Execute();

The first name, last name, and email address are being captured, but not the address.  Any thoughts?  Is "homeadr" the correct key for the address array?  I tried "address" as well, but that didn't work either...

Mar 8, 2011 at 8:48 PM

Unlike some ESP's MailChimp doesn't have a pre-defined address field (only the sub-fields for the address type field have a set name) - you have to create the field in your list as one of the merge_vars.

Create an address type field, and assign a tag name of your choosing. Then, use the tag name where you currently have "homeadr" and it looks like you're good to go.

One of the semi-annoying things that MC does, is that if you try to assign a value to a merge_var that doesn't exist, you get a silent fail on the assignment - with no indication of why it didn't update.
Nice that it adds the subscriber, but dangerous for the fact that it might not be in the state you expect.

Hope that helps,


Mar 8, 2011 at 9:42 PM

Okay, I think I have it working now.  Thanks for your quick reply!