Skip to content

Instantly share code, notes, and snippets.

@hrishimittal
Created April 6, 2021 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrishimittal/98836e78266c9f7cadc8721d95008d55 to your computer and use it in GitHub Desktop.
Save hrishimittal/98836e78266c9f7cadc8721d95008d55 to your computer and use it in GitHub Desktop.
Add email to Mailchimp group via API
def add_to_mailchimp_group(email)
gibbon = Gibbon::Request.new
gibbon.lists('some_list_id')
.members(Digest::MD5.hexdigest(email.downcase).downcase)
.upsert(body: {
email_address: email,
status: "subscribed",
interests: {'some_group_id' => true},
merge_fields: {"MERGE1" => 'merge_field_value'}
})
rescue Gibbon::MailChimpError => e
#Handle the error
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment