The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Custom fields in custom campaigns, v2 API

SOLVED
Go to solution
Highlighted
Occasional Contributor

Custom fields in custom campaigns, v2 API

Hi, I'm trying to get custom fields in my v2 campaigns but can't seem to get the fields to actually show up in the email.

 

My custom XHTML template looks something like:

 

 <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:cctd="http://www.constantcontact.com/cctd">
 <body>
 custom field: $Subscriber.Custom.CustomField1 <br/>
 </body>
 </html>

 

and the single contact in my contact list has a CustomField1 property:

 

$ curl 'https://api.constantcontact.com/v2/contacts/(omitted)'
... "custom_fields":[{"name":"CustomField1","label":"CustomField1","value":"1234"}],...

 

but the "1234" value doesn't actually show up when I send a message (a real message to a real contact, not a test message).

 

I've tried every combination of <Property XHTML tags and $Subscriber variables I can think of but can't seem to get the custom field injected into the template.  There are about a dozen docs on the developer site suggesting different ways to do it, but I fear they're all specific to v1.  Is this sort of thing supported in v2?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Honored Contributor

Re: Custom fields in custom campaigns, v2 API

Hello,

 

After doing a good bit of digging, I believe that the issue you are running into here is that your emails are formatted a custom HTML rather than XHTML. This is important as HTML formatted emails intentionally do not merge data other than a greeting, while XHTML emails will merge contact data. You can fix this when you create the campaign by changing the format.

 

If you are creating a campaign through the UI for testing, you simply need to select XHTML. If you are creating the campaign through the V2 API, you need to set the email_content_format property to "XHTML" instead of "HTML".

 

Once you change this, you should see the custom fields being merged properly when you do a live send to a test list.

 

Best Regards,

Elijah G.
API Support Engineer

View solution in original post

2 REPLIES 2
Highlighted
Honored Contributor

Re: Custom fields in custom campaigns, v2 API

Hello,

 

After doing a good bit of digging, I believe that the issue you are running into here is that your emails are formatted a custom HTML rather than XHTML. This is important as HTML formatted emails intentionally do not merge data other than a greeting, while XHTML emails will merge contact data. You can fix this when you create the campaign by changing the format.

 

If you are creating a campaign through the UI for testing, you simply need to select XHTML. If you are creating the campaign through the V2 API, you need to set the email_content_format property to "XHTML" instead of "HTML".

 

Once you change this, you should see the custom fields being merged properly when you do a live send to a test list.

 

Best Regards,

Elijah G.
API Support Engineer

View solution in original post

Highlighted
Occasional Contributor

Re: Custom fields in custom campaigns, v2 API

Elijah, that was it!  Thank you! 

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured