Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update groupings via Mailchimp API?

I'm trying to subscribe and update members of a Mailchimp list from my Rails 3.2 app via the API.

Everything is working fine, except that I am unable to set interest groups.

What is the correct format for setting groupings.

I've tried

merge_vars: 'GROUPINGS'  => [
  [ 
    'id' => group_id,
    'groups' => ['array', 'of', 'groups']
  ]
]

and

merge_vars: 'GROUPINGS'  => [
  [ 
    'id' => group_id,
    'groups' => "comma,separated,groups"
  ]
]

and

merge_vars: 'GROUPINGS'  => [
  0 => [ 
    'id' => group_id,
    'groups' => "comma,separated,groups"
  ]
]

and several other variations.

Nothing seems to work and the docs are unclear

like image 783
Andy Harvey Avatar asked Jun 21 '13 11:06

Andy Harvey


1 Answers

Took me some time but I finnaly figured out the correct format :

@gb.lists.subscribe({:id => list_id,
                     :email => {:email => self.email},
                     :merge_vars => {:FNAME => self.firstname,
                                     :groupings => [{:id => grouping_id,
                                                     :groups => ["name","of","groups"]
                                                   }]
                                    },
                     :double_optin => false,
                     :send_welcome => false,
                     :update_existing => true})

I'm using rails 3.1.11 and gibbon 0.5.0

Hope this will help !

like image 121
Benjamin Boccara Avatar answered Sep 29 '22 18:09

Benjamin Boccara