Mad Mimi

Audience Import

POST to with the following parameters:

Your Mad Mimi username
Your Mad Mimi api_key
A csv_file (which can be unstructured input)
(Optional) The name of the audience_list you want to import into

Sample input

The CSV file should contain a header row that contains column names like 'email', 'first name', 'last name'. Email is the only required column. Custom columns, like the car column in the example below, can be added and then used in promotions just like any other personalization tags.

An example of a CSV file:

    email,first name,last name,car,Dave,Hoover,Ford,Colin,Harris,Chevy

Importing into audience lists

Audience lists are also supported in a CSV file. Simply add a column titled 'add_list' that contains the name of the list you would like the email added to.

An example:

email,first name,last name,add_list,Dave,Hoover,customer,Colin,Harris,investor

Removing from audience lists

By adding a 'remove_list' to your column headings in your CSV file, you can tell Mad Mimi to remove certain email addresses from particular lists.

An example:

email,first name,last name,remove_list,Dave,Hoover,customer,Colin,Harris,investor


Suppression is also supported in a CSV file. Simply add a column titled 'opt_out' that contains a 1 for suppress, 0 for unsuppress and is blank for no change

An example:

email,first name,last name,opt_out,Dave,Hoover,1,Colin,Harris,0,John,Davis,

In the example, Dave would be suppressed, Colin would be unsuppressed and John would remain (un)suppressed.

Ruby audience import sample code

require 'rubygems'
require 'httparty'
require 'hpricot'
class MadMimiImport
  include HTTParty
  base_uri ''
  USERNAME = 'your@madmimi.username'
  API_KEY = '000your000api000key000'
  LIST_NAME = "the_name_of_the_list_to_import_into"
def run
  get_import_list # get the id of the list we want to import into from the name so we can use it for progress later
  puts "#{LIST_NAME} has an id of #{@list_id}"
  puts "Importing..."
  puts "Import has started..."
  have_progress = false # let's see if we've got progress before, so we know when to stop polling
  while true do
    progress = get_progress # get the progress
    have_progress = true if progress > 0
    puts "Progress #{progress}%"
    break if have_progress && progress >= 100
    sleep 1 # sleep a bit so the import has time to progress
  puts "Import complete"
def get_import_list
  lists_xml = self.class.get("/audience_lists/lists.xml?username=#{USERNAME}&api_key=#{API_KEY}")
  lists_doc = Hpricot(lists_xml.body)
  @list_id = (lists_doc/"list").detect { |list| list["name"] == LIST_NAME }["id"]
def do_import
  csv_file ="large_test_import.csv")'/audience_members', :body => {
    :username => USERNAME,
    :api_key => API_KEY,
    :audience_list => LIST_NAME,
    :csv_file => csv_file,
def get_progress
  progress_xml = self.class.get("/audience_lists/#{@list_id}/pending_total_progress.xml?username=#{USERNAME}&api_key=#{API_KEY}")
  progress_doc = Hpricot(progress_xml.body)
import =