1. Is it possible to add a campaign to a folder via the API? I don't see it documented, but I may have missed it.
2. The situation is that I want much more dynamic logic in the emails than simply using custom fields would allow, so I'm considering building the HTML from an external script and creating a campaign for each individual email. That would seriously clutter up the campaign list if they can't be sorted into a folder. It'd be pretty crappy for analytics too.
As an alternative, is there some way of basically swapping out the entire HTML content of a campaign for each contact it sends to? That way I could reuse a few campaigns but have infinitely dynamic content.
Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.
Our system isn’t really configured to send individual emails like that, as Constant Contact is built primarily for sending bulk emails to lists of contacts, and sending a large amount of emails to lists that only contain one contact could potentially make viewing campaign reporting and statistics cumbersome.
There aren't any API endpoints available as far as campaign folder management, which is strictly a function within the Website UI. Also, campaigns placed in folders still all remain on the Campaign page, so they function as more of a bookmark for campaigns that you want to easily access, such as those used for templates.
However, there are certain ways that you could potentially work around this with an HTML Custom Code email template using custom contact fields in combination with the use of a URL link shortener (such as https://www.bitly.com or https://tinyurl.com), in order to better meet the character limitations.
You don't necessarily have to build out a program for this using the API, and could potentially do it manually by uploading spreadsheets with the contact data and then pasting in your HTML template to a custom code template, but it would likely be exponentially easier to push the data, especially for the custom fields, via the API.
You'd want to start out by building the HTML email template and making it as complete as possible. I'd recommend designating what specific areas of the email will require custom content and building the template structure around them.
You can configure up to 100 custom fields in your Constant Contact account, with the name of the field (internal) allowing upto 50 characters for the label, and the value of the custom field allowing up to 255 characters. The text within the custom fields will work correctly within the HTML code, even if a link is broken up and then concatenated within using custom fields like in the example below, so you could break up blocks of custom content (text/images/links) between the fields:
Custom fields containing two halves of a URL:
Code with consecutive custom fields:
<img src="[[custom.05]][[custom.06]]" />
Will read the full URL and display the image on send:
<img src="https://conta.cc/3LS54Dc" />
Designing HTML for Custom Code Emails
Though, something important to keep in mind when using custom fields is that they're not going to be visible when previewing the email prior to send, nor in the permanent URL version of a sent campaign. So, when you're testing the custom fields within the context of the HTML for the Custom Code, you'll want to set up a list with some test addresses that you have access to so that you can do live test sends to verify that everything is populating correctly.
Please have a look and let us know if you have any other questions!
View API documentation, code samples, get your API key.Visit Page
Join our list to be notified of new features and updates to our V3 API.Sign Up