• Resolved Matt Radford

    (@mattrad)


    Hi. Thanks for this nice plugin. Could you suggest filtering per-campaign? At the moment the block outputs all newsletters for the Mailchimp account, but I need to filter these to one campaign only.

    I can see you’ve added a filter at the end of \CABFM\Blocks::render_block(), but in $campaigns I can’t see a way to uniquely identify particular campaigns. Perhaps I’m misunderstanding how Mailchimp campaigns work.

    Thanks for any advice you have.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Bernhard Kau

    (@kau-boy)

    Hi Matt,

    thanks for reaching out. I was also confused in the beginning on how this works with Mailchimp. In their terminology, a “campaign” if a single sent “newsletter email”. Those can be grouped in “campaign folder”. In the single campaign you will find a “folder_id” which you could use to filter the campaigns.

    I’ve added a filter to make this possible, but I just realized that I used the wrong name there. Before you use it, please give me some time tomorrow to fix the name.

    Filtering campaigns by folder and by date is something I wanted to add to a future version of the plugin, but for the first release this was a bit too complex.

    For your use-case, would it help you to have a filter to alter the campaign before they go into the foreach loop?

    Plugin Author Bernhard Kau

    (@kau-boy)

    Hi Matt,

    I’ve just released a new version. You can now use the filter cabfm_campaigns_query_args to add arguments to the Mailchimp API call and cabfm_campaigns_markup to modify the rendered markup.

    You could use the “folder_id” field to filter for the “campaign folder”: https://mailchimp.com/developer/marketing/api/campaigns/list-campaigns/

    Thread Starter Matt Radford

    (@mattrad)

    Thank you for being so willing to make some changes Bernhard 🙂 I haven’t had a chance to test this out yet, but will do later this week and will report back.

    Thread Starter Matt Radford

    (@mattrad)

    Hi Bernhard

    I’ve tested this now and it works with the filter, many thanks!

    One thing though: Mailchimp don’t make it wasy to get the folder ID. There is an “f_folder” in the URL when you navigate to the folder, but that’s not it. I had to make a GET request to the /campaign-folders endpoint to list them all, and the response shows that the folder_id needed is in the format “ab7abba2f8”. Once I’d added a filter to add that to the $query_args, it worked as expected. So one enhancement, should you be inclined, would be to make that campaign-folders request in the Settings and offer a list of Campaign folders to display.

    Thanks again 🙂
    Matt

    Plugin Author Bernhard Kau

    (@kau-boy)

    Hi Matt,

    that’s exactly the feature I’m currently working at. I already finished the part getting the folder names and IDs from the Mailchimp API. Now I “only” have to implement the block setting with a dropdown to select those folders. But this is still the hard part for me as I still haven’t completely learned how to load dynamic data into blocks/React. I have the custom REST endpoint bug still need some lines of JS code to make them work 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filter by campaign’ is closed to new replies.