I'm having a problem replacing mc:edit
content areas in Mailchimp with the content that I provide.
The email is sent out to the subscribers, but none of the content provided is added to the email. Can anyone see where I might be going wrong?
This is the script that I am using:
campaign = mailchimp.campaigns.create(
"regular",
{
"list_id" => list_id,
"subject" => "Email Test",
"from_email" => "[email protected]",
"from_name" => "Edward",
"to_name" => "The to name",
"template_id" => 35089
},
{
"sections" =>
{
"commit_stuff" => "Modified project to use XYZ ruby gem. #ABC-123",
"content" => "This is the content",
"more-content" => "This is more content"
}
}
)
result = mailchimp.campaigns.send(campaign["id"])
And this is the section inside the email that I am trying to modify:
<div mc:edit="commit_stuff" class="mcnTextContent">Use your own custom HTML</div>
<div mc:edit="content"></div>
<div mc:edit="more-content"></div>
Relevant docs:
As per @kateray comment above, after an hour of tries I managed to insert my custom HTML from my back-end as the MailChimp campaign content via its API 3.0. For such a simple use case it is rather annoying not to have a ready-made solution on their docs. Surely MailChimp API lacks a cookbook.
So from the beginning:
a) Create the mailing list with API or with MailChimp web interface - create list and b) add the recepients to it - add members.
Create the new campaign via API create campaign or their website. Do not assign any template to it.
Assign the mailing list to the camplaign assign mailing list.
Now set the campaign content with this API endpoint. Assign the following value to the JSON body of the request you send to the endpoint:
{
"html": "<p>This is your custom HTML assigned to your campaign as content.</p>"
}
and send the request.
In the response to this request you get the HTML you set and its plain text version.
Go in the MailChimp web interface and ensure the campaign has all the check marks green.
Send out the campaign with this API request.
NB:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With