We’ve gotten feedback that users want a simple way to add contacts into their Constant Contact account without having to redirect the contact to our website to finish the process. This method keeps the contact on your page and doesn’t require advanced programming knowledge.
You can now add contacts directly into your account from your webpage or application using this simple post URL. You can also use the embed code as it is, and paste it into your website. That’s found by logging in and going to Contacts>>Sign-up Tools>>Embed Code. Another article, How To Modify Embed Code, focuses on how that embed code can be changed.
This article will focus on constructing the raw request, and is for our very technical users with HTML and CSS coding experience. In order to use the POST URL, your web page or application must be able to make a HTTPS call to the following URL:
The “ca” value identifies the account to which to add the new contact. This property is unique for each Constant Contact account. You can find the “ca” value for an account by logging in and going to Contacts>>Sign-up Tools>>Embed Code. Copy the embed code, and find the “ca” parameter. Paste the value that follows into your sign-up form URL. If you have multiple embedded sign-up forms in one account, any of the “ca” values will work.
Note: this signup method doesn’t require an API Key or token like our full API.
Where to find the ca id
The ca id is shown in the embed code in a snippet like below. It is the hashed string after “value.”
name="ca" type="hidden" value="12345-678-910" data-id="ca:input"
|address_city||City the contact lives in.|
|address_country||The contact's country; Standard ISO 3166-1 2-letter country code|
|address_postal_code||The contact's Postal ZIP code.|
|address_state||State that the contact lives in.|
|address_street||The contact's street address|
|anniversary_day||Must include anniversary_year and anniversary_month when using anniversary_day. The day of the contact's anniversary, accepts numbers 1 - 31.|
|anniversary_month||Must include anniversary_year and anniversary_day when using anniversary_month.The month of the contact's anniversary, accepts numbers 1 - 12.|
|anniversary_year||Must include anniversary_day and anniversary_month when using anniversary_year.The year of the contact's anniversary, accepts numbers 1900 and higher, up to 10 years in the future.|
|birthday_day||Must include birthday_month when using birthday_day. The day of the contact's birthday, accepts numbers 1 - 31.|
|birthday_month||The month of the contact's birthday, accepts numbers 1 - 12.|
|ca||Yes||Campaign Activity ID that identifies and authenticates the Constant Contact account owner. Retrieve this value by logging in your Constant Contact account and going to Contacts>>Sign-up Tools>>Embed Code, and look for ca ID.|
|company||The contact's company|
|Yes||The contact's email address, must comply with RFC 5322.|
|first_name||The contact's first name|
|job_title||The contact's job title|
|last_name||The contact's last name|
|list||List ID's that the contact will be subscribed to. If blank, the contact will be added to the lists configured with the signup form in the product UI. This field takes the numeric list ID's, which can be found in the Embed Code.|
|phone||The contact's home phone number|
|url||URL to redirect the subscriber to after successfully submitting subscription. If blank, endpoint returns a 200 Success response.|
Here’s the URL you might construct to add a contact to a couple of lists.
https://visitor2.constantcontact.com/api/signup?ca=xxxxx &firstname.lastname@example.org&first_name=Joe &list=xxxx&list=xxxxx
Lists and the Additive Effect
The ‘list’ parameter specifies the list(s) to which to add the new contact. If no lists are specified in the URL, the contact is added to the lists specified in the sign-up form in the product UI.
If the email address already exists in your account, the POST updates their record with the information included using this method. They will remain on any lists that they are already subscribed to; the effect of this method is additive. Similarly, any fields not specified in the request will remain in the contact record.
Creating a Sign-up Form
Here’s an example of a simple signup form that you could place on your website to send contacts into the list specified by the sign-up form in your account. The form below sends the contact to a new page when they submit their information.
<form action="https://visitor2.constantcontact.com/api/signup" method="post"> <p>Join our email list to receive updates and specials!</p> <input name="email" type="email" placeholder="Email" size="30" required> <br/><br/> <input name="first_name" placeholder="First name" size="30"><br/><br/> <input type="hidden" name="ca" value="your-ca-value"> <input type="hidden" name="url" value="http://www.constantcontact.com/"> <input type="submit"> </form>
That looks roughly like this, depending on what browser and OS you’re using. Apply your own CSS to make it prettier.
In this example, the contact is sent to http://www.constantcontact.com upon successful submission. Replace the “url” value with your own custom “Thank you for signing up” webpage, beginning with http. If an error occurs when the contact is submitted to us, this form will send the contact to our page, visitor2.constantcontact.com, and will show the user the error. A more advanced script, like the jQuery example below, is required to keep the user on their current page when the form is submitted.
jQuery Signup Form
Here’s an example jQuery/AJAX script that submits the contact to us without refreshing your website page or sending the contact to a new destination. You should use something like this if you do NOT want to send the user to a new thank you page when they submit their data. They’ll see a success or error message on the same page after they submit their email.
There are 3 parts to this form: the jQuery header that allows the client to process the script, the jQuery script itself, and the HTML form that the user sees.
Possible responses from our service
|Contact created/updated successfully||200||Welcome page (customizable)|
|Missing parameter||400||Error page: "Missing required field: ..."|
|Invalid e-mail address||400||Error page: "Invalid e-mail address..."|
|Rate limit exceeded||429||Error page: "Sorry, our signup volume is too high. Please try again later."*|
* Note that this is for security. Each account is limited to 500 submissions per 24-hour period, on a revolving timer.
The character limits on contact fields are defined here, in addition to being in the embed code.
- Be aware that the lists specified need to remain in the account. If a list is deleted, the sign-up form should be updated.
- Record any error message body received back from us. For example, if we give you a 400 error, that error code is accompanied by a reason, like that the email address was invalid. Display that message to help you and your contacts figure out what went wrong.
For support, email email@example.com. Our more advanced tier 1 support agents, and our tier 2 agents can assist. We DO NOT monitor this post’s comments, so please do not comment on the article for support. Our support teams can ensure that you are forming the POST request properly and that the submitted data is in the correct format, but we do not have resources to help with the formatting or display of signup forms.