Our company uses JSON feeds as datasources for our emails. We are moving over to ExactTarget and there doesn't seem to be much documentation surrounding this.

How would you use a JSON feed instead of an RSS feed in the following example?

How to Include an RSS Feed in an Email Message using AMPScript


You'd likely not use AMPScript for this as SSJS handles JSON natively. You could try putting SSJS into your email, but you'd be on your own with respect to Tech Support with any issues you encounter with sending these emails. They don't have much of a sense of humour when it comes to SSJS in emails - the performance is poor and the back-end logging tech support has access to is pretty non-existent.

My advice would be to use a Landing Page to do the transformation from JSON to HTML using SSJS and include this in your email by doing a HTTPGet() to the Landing Page. If it's the same content for more or less everyone, make sure you use the TreatAsContentArea() AMPScript function around the HTTPGet() or use a before;httpget command in the content area in the email to cache the content and avoid making many wasteful calls to this page to get the same content.

This example I put together a few years ago isn't exactly syndication, but the final section on the "Sample Contact Page" shows making a HTTPGet() with SSJS and interrogating the JSON response, which is pretty much what you need to do...

Retrieving Information From a Third Party API Using a Landing Page

  • This is great. I think we will just use HTTPGet() and pull a page from our server, and not worry about the feed. If you do not use before; or TreatAsContentArea(), will it pull the page for each recipient? So if we have 40,000 subscribers, it would pull 40,000 times? – ok1ha Dec 9 '15 at 18:34
  • 1
    Yes. If you do not encapsulate your content area in TreatAsContentArea(), you'll hammer your web server and the email will take for ever to send as it makes an HTTP request out for each subscriber. TreatAsContentArea creates what's known as a "Virtual Content Area". This is created the first time TreatAsContentArea is used for the key provided. Thereafter, each subscriber uses this cached copy of the content. – Macca Dec 11 '15 at 1:56

Macca's answer is correct that SSJS is the only native way to handle a JSON file via Exact Target's server-side scripting. This can lead to a very slow send time though and there is very little support or documentation for you to utilize. (best documentation I can find - https://help.exacttarget.com/en-US/documentation/exacttarget/content/server_side_javascript/server_side_javascript_syntax_guide/

You do have a couple other options though:

1.) Convert your JSON to XML (there are many options server-side and client-side for this) and use the AMPScript BuildrowsetfromXML option to create a datatable for you to pull the info from.

2.) Create a Data Extension to house your info and then use REST API to send the info into the Data Extension for reference in your email via AMPscript.

3.) Use Fuel SDK to create an app to allow you to create and customize the email as needed in Exact Target via your language of choice. https://code.exacttarget.com/apis-sdks/fuel-sdks/emails/email-create.html

The best option would be if you can convert the JSON to XML(#1) as it would be the least effort while remaining fairly efficient. If you are willing to put in the extra time or extra money to develop it, #3 would be the most efficient and customizable long term solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.