How to use an existing static segment for a new campaign?

598 views
Skip to first unread message

Mario Hofer

unread,
Oct 22, 2013, 3:19:16 AM10/22/13
to mailchimp-...@googlegroups.com
Hi,

I'm going nuts with this! :-)

With the API 2.0 I created some segments in my list. Now I want to create a campaign using these segments. I have the IDs, but it seems, that there is no option to pass a segment ID when creating a new campaign.

Am I wrong? Hopefully...

Ah, yes, I did take a look at these segment_opts thing, but I didn't understand it. And the saved_segment_id I pass as third parameter of campaign-create like this (but doesn't work): array('saved_segment_id' => (string) $_segment['id']);

Any help appreciated!

Best, Mario

jesse

unread,
Oct 22, 2013, 5:54:21 AM10/22/13
to mailchimp-...@googlegroups.com
Yes, that - and if you're using our PHP wrapper, the segment_opts parameter is 4th, not 3rd.


jesse

Mario Hofer

unread,
Nov 4, 2013, 7:46:34 AM11/4/13
to mailchimp-...@googlegroups.com
Good to hear, but it still doesn't work. The error message is:

[User Error] Uncaught Mailchimp_Invalid_Options: A saved segment with id "27681"does not exists for this list.

The code looks like:

$_segmentOptions = array('saved_segment_id' => $_segment['id']);
$_mailChimp->campaigns->create($_campaignType, $_campaignOptions, $_campaignContent, $_segmentOptions);

The segment definitely exists and I also can select it manually. But how to do it via the API?

Best, Mario


PS: I'm using your PHP wrapper.

Mario Hofer

unread,
Nov 5, 2013, 2:40:18 AM11/5/13
to mailchimp-...@googlegroups.com
Ok, here is a workaround creating a new segment and checking against the static one:

 
 $_segmentOptions
= array(
   
'match' => 'all',
   
'conditions' => array(
     array
(
       
'field' => 'static_segment',
       
'op' => 'eq',
       
'value' => (string) $_segment['id']
     
)
   
)
 
);


But shouldn't be there an easier way, Jesse?

Eric Muntz

unread,
Nov 5, 2013, 10:01:25 AM11/5/13
to mailchimp-api-discuss
Hey Mario,

Sorry about that, you are right and it's a bug.  We're working to get it fixed so any saved segment can be passed as the "saved_segment_id" parameter - right now it's only saved segments that aren't static segments.  I'll let you know when it's been fixed.


--
You received this message because you are subscribed to the Google Groups "MailChimp API Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mailchimp-api-di...@googlegroups.com.
To post to this group, send email to mailchimp-...@googlegroups.com.
Visit this group at http://groups.google.com/group/mailchimp-api-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Eric Muntz

unread,
Nov 5, 2013, 10:35:04 AM11/5/13
to mailchimp-api-discuss
Hey Mario - that's fixed now, give it a try with just the 'saved_segment_id' parameter with your static segment's id.


On Tue, Nov 5, 2013 at 2:40 AM, Mario Hofer <mario...@knsqnt.com> wrote:

--

Mario Hofer

unread,
Nov 13, 2013, 10:44:50 AM11/13/13
to mailchimp-...@googlegroups.com
Wow, that took me hours! But that's how life is :-) Thanks for the fix, I'll test it and give feedback here.
To unsubscribe from this group and stop receiving emails from it, send an email to mailchimp-api-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages