Method: Mailchimp::Campaigns#create
- Defined in:
- lib/mailchimp/api.rb
#create(type, options, content, segment_opts = nil, type_opts = nil) ⇒ Hash
Create a new draft campaign to send. You <strong>can not</strong> have more than 32,000 campaigns in your account.
Parameters:
-
type
(String)
—
the Campaign Type to create - one of “regular”, “plaintext”, “absplit”, “rss”, “auto”
-
options
(Hash)
—
a struct of the standard options for this campaign :
- String
-
list_id the list to send this campaign to- get lists using lists/list()
- String
-
subject the subject line for your campaign message
- String
-
from_email the From: email address for your campaign message
- String
-
from_name the From: name for your campaign message (not an email address)
- String
-
to_name the To: name recipients will see (not email address)
- Int
-
template_id optional - use this user-created template to generate the HTML content of the campaign (takes precendence over other template options)
- Int
-
gallery_template_id optional - use a template from the public gallery to generate the HTML content of the campaign (takes precendence over base template options)
- Int
-
base_template_id optional - use this a base/start-from-scratch template to generate the HTML content of the campaign
- Int
-
folder_id optional - automatically file the new campaign in the folder_id passed. Get using folders/list() - note that Campaigns and Autoresponders have separate folder setups
- Hash
-
tracking optional - set which recipient actions will be tracked. Click tracking can not be disabled for Free accounts.
- [Bool] opens whether to track opens, defaults to true - [Bool] html_clicks whether to track clicks in HTML content, defaults to true - [Bool] text_clicks whether to track clicks in Text content, defaults to false- String
-
title optional - an internal name to use for this campaign. By default, the campaign subject will be used.
- Boolean
-
authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false.
- Hash
-
analytics optional - one or more of these keys set to the tag to use - that can be any custom text (up to 50 bytes)
- [String] google for Google Analytics tracking - [String] clicktale for ClickTale tracking - [String] gooal for Goal tracking (the extra 'o' in the param name is not a typo)- Boolean
-
auto_footer optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports
- Boolean
-
inline_css optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
- Boolean
-
generate_text optional Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false.
- Boolean
-
auto_tweet optional If set, this campaign will be auto-tweeted when it is sent - defaults to false. Note that if a Twitter account isn’t linked, this will be silently ignored.
- Array
-
auto_fb_post optional If set, this campaign will be auto-posted to the page_ids contained in the array. If a Facebook account isn’t linked or the account does not have permission to post to the page_ids requested, those failures will be silently ignored.
- Boolean
-
fb_comments optional If true, the Facebook comments (and thus the <a href=“kb.mailchimp.com/article/i-dont-want-an-archiave-of-my-campaign-can-i-turn-it-off/” target=“_blank”>archive bar</a> will be displayed. If false, Facebook comments will not be enabled (does not imply no archive bar, see previous link). Defaults to “true”.
- Boolean
-
timewarp optional If set, this campaign must be scheduled 24 hours in advance of sending - default to false. Only valid for “regular” campaigns and “absplit” campaigns that split on schedule_time.
- Boolean
-
ecomm360 optional If set, our <a href=“www.mailchimp.com/blog/ecommerce-tracking-plugin/” target=“_blank”>Ecommerce360 tracking</a> will be enabled for links in the campaign
- Hash
-
crm_tracking optional If set, a struct to enable CRM tracking for:
- [Hash] salesforce optional Enable SalesForce push back - [Bool] campaign optional - if true, create a Campaign object and update it with aggregate stats - [Bool] notes optional - if true, attempt to update Contact notes based on email address - [Hash] highrise optional Enable Highrise push back - [Bool] campaign optional - if true, create a Kase object and update it with aggregate stats - [Bool] notes optional - if true, attempt to update Contact notes based on email address - [Hash] capsule optional Enable Capsule push back (only notes are supported) - [Bool] notes optional - if true, attempt to update Contact notes based on email address
-
content
(Hash)
—
the content for this campaign - use a struct with the one of the following keys:
- String
-
html for raw/pasted HTML content
- Hash
-
sections when using a template instead of raw HTML, each key should be the unique mc:edit area name from the template.
- String
-
text for the plain-text version
- String
-
url to have us pull in content from a URL. Note, this will override any other content options - for lists with Email Format options, you’ll need to turn on generate_text as well
- String
-
archive to send a Base64 encoded archive file for us to import all media from. Note, this will override any other content options - for lists with Email Format options, you’ll need to turn on generate_text as well
- String
-
archive_type optional - only necessary for the “archive” option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz . If not included, we will default to zip
-
segment_opts
(Hash)
(defaults to: nil)
—
if you wish to do Segmentation with this campaign this array should contain: see campaigns/segment-test(). It’s suggested that you test your options against campaigns/segment-test().
-
type_opts
(Hash)
(defaults to: nil)
—
various extra options based on the campaign type
- Hash
-
rss For RSS Campaigns this, struct should contain:
- [String] url the URL to pull RSS content from - it will be verified and must exist - [String] schedule optional one of "daily", "weekly", "monthly" - defaults to "daily" - [String] schedule_hour optional an hour between 0 and 24 - default to 4 (4am <em>local time</em>) - applies to all schedule types - [String] schedule_weekday optional for "weekly" only, a number specifying the day of the week to send: 0 (Sunday) - 6 (Saturday) - defaults to 1 (Monday) - [String] schedule_monthday optional for "monthly" only, a number specifying the day of the month to send (1 - 28) or "last" for the last day of a given month. Defaults to the 1st day of the month - [Hash] days optional used for "daily" schedules only, an array of the <a href="http://en.wikipedia.org/wiki/ISO-8601#Week_dates" target="_blank">ISO-8601 weekday numbers</a> to send on - [Bool] 1 optional Monday, defaults to true - [Bool] 2 optional Tuesday, defaults to true - [Bool] 3 optional Wednesday, defaults to true - [Bool] 4 optional Thursday, defaults to true - [Bool] 5 optional Friday, defaults to true - [Bool] 6 optional Saturday, defaults to true - [Bool] 7 optional Sunday, defaults to true- Hash
-
absplit For A/B Split campaigns, this struct should contain:
- [String] split_test The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaigns/schedule() separately! - [String] pick_winner How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually) - [Int] wait_units optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400. - [Int] wait_time optional the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day. - [Int] split_size optional this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10% - [String] from_name_a optional sort of, required when split_test is "from_name" - [String] from_name_b optional sort of, required when split_test is "from_name" - [String] from_email_a optional sort of, required when split_test is "from_name" - [String] from_email_b optional sort of, required when split_test is "from_name" - [String] subject_a optional sort of, required when split_test is "subject" - [String] subject_b optional sort of, required when split_test is "subject"- Hash
-
auto For AutoResponder campaigns, this struct should contain:
- [String] offset-units one of "hourly", "day", "week", "month", "year" - required - [String] offset-time optional, sort of - the number of units must be a number greater than 0 for signup based autoresponders, ignored for "hourly" - [String] offset-dir either "before" or "after", ignored for "hourly" - [String] event optional "signup" (default) to base this members added to a list, "date", "annual", or "birthday" to base this on merge field in the list, "campaignOpen" or "campaignClicka" to base this on any activity for a campaign, "campaignClicko" to base this on clicks on a specific URL in a campaign, "mergeChanged" to base this on a specific merge field being changed to a specific value - [String] event-datemerge optional sort of, this is required if the event is "date", "annual", "birthday", or "mergeChanged" - [String] campaign_id optional sort of, required for "campaignOpen", "campaignClicka", or "campaignClicko" - [String] campaign_url optional sort of, required for "campaignClicko" - [Int] schedule_hour The hour of the day - 24 hour format in GMT - the autoresponder should be triggered, ignored for "hourly" - [Boolean] use_import_time whether or not imported subscribers (ie, <em>any</em> non-double optin subscribers) will receive - [Hash] days optional used for "daily" schedules only, an array of the <a href="http://en.wikipedia.org/wiki/ISO-8601#Week_dates" target="_blank">ISO-8601 weekday numbers</a> to send on< - [Bool] 1 optional Monday, defaults to true - [Bool] 2 optional Tuesday, defaults to true - [Bool] 3 optional Wednesday, defaults to true - [Bool] 4 optional Thursday, defaults to true - [Bool] 5 optional Friday, defaults to true - [Bool] 6 optional Saturday, defaults to true - [Bool] 7 optional Sunday, defaults to true
Returns:
-
(Hash)
—
the new campaign’s details - will return same data as single campaign from campaigns/list()
1539 1540 1541 1542 |
# File 'lib/mailchimp/api.rb', line 1539 def create(type, options, content, segment_opts=nil, type_opts=nil) _params = {:type => type, :options => options, :content => content, :segment_opts => segment_opts, :type_opts => type_opts} return @master.call 'campaigns/create', _params end |