We are developing a website where visitors can download whitepapers when they subscribe to our simple mail list. I made a API connection with Mailchimp. So every subscriber is added to a Mailchimp list.
Since we have different services we provide I love to segment this signups in different groups of listst.
I was wondering if it is possible to change my list id or group id inside a controller controller by a page blueprint field. Then I have the possibility for every page which form (list id/group id) I use in my controller.
While this plugin is for Mailjet instead of mailchimp, you might get ideas there: https://github.com/bnomei/kirby3-mailjet/wiki/Mailjet:-Segments
Thank you. I don’t understand exactly how it is done.
What would you advice? Trying to reproduce the plugin for Mailchimp or is there a more simplicity solution.
Hello @portobien, did you find an answer to integrate mailchimp in Kirby? I’m planning to do the same, I’m might gain from your experience… Thank you
What exactly do you need? After all, depending on your needs, e.g. subscribing someone to a mailing list, such an “integration” is nothing more than sending a POST request to the MailChimp API.
Here is an example: AJAX Form with Mailchimp Add Subscriber (+ Uniform Plugin)
Thank you, I will look at it. (What I need is time, know-how and experience, shortcuts I suppose… all related)
Feel free to come back with any specific questions you might have.
What I was trying to bring across is that it doesn’t always need a sophisticated plugin to get a job done. When new to something, we tend to back away from doing things, because we think we can’t do it and that we need a plugin. After all, integration sounds like something big and complicated. Of course, if you need something that does all the things that for example, @bnomei’s Mailjet plugin does, then yes, that’s not so easy and takes time and experience to implement.
But often, we don’t need all the stuff that is in such a plugin.
Starting simple and doing things step by step with the help of the community will finally get you there and as an extra bonus, you learn something along the way. Much more satisfying than installing just another plugin.
You can do with with a curl request:
$list_id = 'YOURLISTID';
$authToken = 'YOURAUTHTOKEN';
$postData = array(
"email_address" => 'field value',
"status" => "subscribed",
"merge_fields" => array(
"FULLNAME" => 'field value',
// more fields....
// Setup cURL
$ch = curl_init('https://us20.api.mailchimp.com/3.0/lists/'.$list_id.'/members/');
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Authorization: Basic '.$authToken,
CURLOPT_POSTFIELDS => json_encode($postData)
// Send the request
$response = curl_exec($ch);
That works, but you can shorten a bit using Kirbys built in remote class (I just didnt have time to figure that out when i did the above). Just change the URL, since the first part of that might different. Mailchimp has servers all over the world. You can get the right url and the list id from your mailchimp account.
Also dont forget to properly handle form validation (dont just rely on javascipt or HTML5 validition).
Thank you, for now I choose to go with mailerlite, I will see soon how I can integrate it…
Hi @KrsBee, I was not able to make a ‘plugin’ but get it worked with the php api script from Mailchimp.