When it comes to integrating MailChimp into Rails applications, Hominid is my gem of choice. It’s implementation is relatively straightforward and it stays true to the MailChimp API.
I rarely have issues with it, but I recently needed to funnel users into specific groups which were part of a list and hit a bit of snag with the merge vars parameter of the listSubscribe function.
The API clearly states:
Each element in this array should be an array containing the “groups” parameter which contains a comma delimited list of Interest Groups to add.
And I was attempting to implement it like this:
h.list_subscribe 'my_list_id', user_email, { :GROUPINGS => [ 'name' => 'myGroup', 'groups' => group.name ] }, 'html', false, true, true, false
Notice that I’m passing the merge vars in as a hash and assigning an array to GROUPINGS. But as the API clearly states (and I obviously misread), GROUPINGS should reference an array that contains an array.
But the correct way to assign users to groups using Hominid is:
h.list_subscribe 'my_list_id', user_email, { :GROUPINGS => [ { 'name' => 'myGroup', 'groups' => group.name } ] }, 'html', false, true, true, false
Thought I’d share this just in case anyone else on the planet happens to hit the same snag I did.
Leave a Reply
You must be logged in to post a comment.