We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Custom Fields not populating from API generated Campaign


Custom Fields not populating from API generated Campaign

Intent:Create custom campaigns that allow our contacts to quickly jump to dynamically updated web content based on our contact's preferences.


Documentation References


Field Variable Reference:

Contact Property                Variable Name in Email CampaignImport File Column Name
Email address
$SUBSCRIBER.EMAILEmail Address - Work
Email Address - Home
Mailing address line 1$SUBSCRIBER.ADDRESSLINE1Address Line 1
Mailing address line 2$SUBSCRIBER.ADDRESSLINE2Address Line 2
Mailing address line 3$SUBSCRIBER.ADDRESSLINE3Address Line 3
Mailing address city$SUBSCRIBER.CITYCity
Postal (zip) code$SUBSCRIBER.POSTALCODEZip/Postal Code
Home phone number$SUBSCRIBER.HOMEPHONENUMBER Phone number - Home
Custom Field n (n=1-15)   $SUBSCRIBER.CUSTOMTEXTnCustom Field n



$SUBSCRIBER.CUSTOMTEXT1 would be replaced with the contact s first custom field value. There are 15 custom fields available, to determine which custom field data exists as $SUBSCRIBER.CUSTOMTEXT1 to $SUBSCRIBER.CUSTOMTEXT1 5 add the variables to the campaign's email content in order from 1-15 to make the determination.


Example Provided in Documentation

<h4>Thank you for being a part of our $SUBSCRIBER.CUSTOMTEXT1 class!</h4>
<p>We thought you'd also like this $SUBSCRIBER.CUSTOMTEXT2 class, offered next $SUBSCRIBER.CUSTOMTEXT3.</p>
<p><a href="http://mydomain.com/classes?email=$SUBSCRIBER.EMAIL">Click here to Register!</a></p>
<p>I hope to see you there!</p>
<p>Your friends at Wallace Dance Co.</p>


Campaign JSON Struct Example, modified to include XHTML and $SUBSCRIBER.CUSTOMTEXT1 reference

  1. {
  2. "name": "Test Campaign 1351175725",
  3. "subject": "This Week's Specials",
  4. "from_name": "My Organization",
  5. "from_email": "from-email@example.com",
  6. "reply_to_email": "reply-to-email@example.com",
  7. "status": "DRAFT",
  8. "is_permission_reminder_enabled": true,
  9. "permission_reminder_text": "Hi, just a reminder that you're receiving this email because you have expressed an interest in MyCompany. Don't forget to add from_email@example.com to your address book so we'll be sure to land in your inbox! You may unsubscribe if you no longer wish to receive our emails.",
  10. "is_view_as_webpage_enabled": true,
  11. "view_as_web_page_text": "Having trouble viewing this message?",
  12. "view_as_web_page_link_text": "Click here to view as a Web page",
  13. "greeting_salutations": "Hello",
  14. "greeting_name": "FIRST_NAME",
  15. "greeting_string": "Dear ",
  16. "email_content": "<html><body><p>This is text of the email message. $SUBSCRIBER.CUSTOMTEXT1 </p></body></html>",
  17. "text_content": "This is the text of the email",
  18. "email_content_format": "XHTML",
  19. "style_sheet": "",
  20. "message_footer": {
  21. "organization_name": "Your Organization",
  22. "address_line_1": "123 Maple Street",
  23. "address_line_2": "Unit 1",
  24. "address_line_3": "",
  25. "city": "Anytown",
  26. "state": "MA",
  27. "international_state": "",
  28. "postal_code": "01444",
  29. "country": "US",
  30. "include_forward_email": true,
  31. "forward_email_link_text": "Forward this message to a friend!",
  32. "include_subscribe_link": true,
  33. "subscribe_link_text": "Sign up for our mailing list!"
  34. },
  35. "sent_to_contact_lists": [
  36. {
  37. "id": "1"
  38. }
  39. ]
  40. }

Attempted this and the custom field variable was replaced with blank

  • Attempted adding $SUBSCRIBER.CUSTOMTEXT1

Same result, no values populated. Confirmed that contacts custom fields had content.

Additional None Issue

Discovered that subject does not allow custom contact data

Resolution Expectation:

Successful method for referencing contact custom fields when creating a campaign.



When we name a custom field custom_field_1 it can be referenced by $SUBSCRIBER.CUSTOMTEXT1

This does not help us with the 298k contacts we have currently uploaded with named custom fields such as userid.



As you found, the options for merging contact details into custom HTML email campaigns (regardless of if they are created through the API) are currently limited to a set of custom fields that follow the naming scheme you described. This does unfortunately mean that you will not be able to merge contact details from fields that bear a name such as "userid".


The best way to resolve this is to re-import the existing contacts with the desired fields for merging stored in new custom fields. You could accomplish this by either using the bulk import functions of our API, which will create fields if they do not yet exist. You can also accomplish your goal by creating the custom fields ahead of time using the format "custom_field_NN" where NN is a number between 1 and 15. Once the fields are created the contacts could be uploaded directly through our UI and simply map the fields on the import files to the desired fields in Constant Contact.


If you have any questions, please let me know!



Elijah G.
API Support Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page