Call An External Data Feed

Follow the instructions below only if you do not import your site’s feed in Sailthru. Most should follow the instructions to import a feed at Data Feeds Overview. The following methods will work for a data feed directly entered into the data feed box of the campaign editor.

Follow the instructions below only if you do not import your site’s feed in Sailthru. Most should follow the instructions to import a feed at Data Feeds Overview. Otherwise, read on.

JSON Data Feeds

The most flexible custom data feed format is JSON. If you provide your data in JSON format, you must use the MIME Content-type header application/json or text/javascriptIn JSON format, you can pass any data you want in the form of a single JSON object. However, be sure to include a “url” field, as this is required for the feed to load in Sailthru.

The top-level keys of the object represent replacement variables in the body of your message. For example, if you had the feed:

 {"main_title":"Today's Email Blast",  "headlines":[{"title":"Headline 0","url":"";},
{"title":"Headline 1","url":""}]}

You could reference the variables in your HTML code with {main_title} or {headlines[0].title}

If you’re not familiar with programming, please note that arrays, such as the above, always start at “0” not “1”.

JSON Key Rules:

Separate words with an underscore ( _ ) instead of hyphen ( – ). You cannot reference keys values with hyphens in Zephyr.

  • Bad: {stream[0].vars.sailthru-doctor}
  • Good: {stream[0].vars.sailthru_doctor}

If you must use a hyphen in a JSON key, wrap the key with square brackets ( [] ) and single quotes ( ‘ ) on the template level. You can how reference these values in Zephyr.

  • Bad: {content.real-estate[0].title}
  • Good: {content[‘real-estate’][0].title}


XML Feeds

XML feeds are converted to JSON in a fairly straightforward way:

  • Individual elements become individual keys
  • Attributes are represented as a key named @attribute
  • When attributes are mixed with content, the content is represented as #text

For example, if your XML looks like:

  <main_title>My Main Title</main_title> <headline title="Headline 1"></headline> <headline title="Headline 2"></headline>


My Main Title {myxml.headlines[0]['@title']}

Headline 1


If are creating a new feed specifically for Sailthru and you have a choice of whether to use XML or JSON, use JSON as it is more straightforward. But XML is very convenient when you are using existing feeds such as RSS.


RSS Feeds

Since RSS feeds are a common XML feed that most sites already have, it’s easy to use your existing RSS feed as your data feed with little development effort.

Typically, you will loop through the array and print each title and link

This can be accomplished as follows:

 {foreach as item} 
    <a href="{}">{item.title}</a> 

However, this use of RSS feeds is discouraged in favor of converting your feeds to Sailthru content feeds (see Data Feeds Overview).

Step by Step Tutorial: RSS/XML

  1. Go to the “Campaigns” section and hit the “Create New” button.
  2. Under the advanced tab, select custom “Custom Feed URL” and enter the following URL:
  3. Enter the following Zephyr code:
    {foreach as item} 
  4. click on the HTML Preview tab, you should see:
    First Item   This is the first Item in our example feed   
    Second Item  This is the second Item in our example feed   
    Third Item   This is the third Item in our example feed

In order to make custom parameters in your RSS or XML feed accessible (in your Template or Campaign) perform the following steps:

1. Change the namespace declaration to:

2. Nest your custom parameters within the <sailthru:vars> tag

Visit our RSS Extension page for an example of both steps one and two


You can also just get a piece of HTML and put it into your email. This approach is discouraged, as it is better to separate your content from presentation, but it is supported.

Simply serve your data feed content as text/html and the entire contents of the feed will go into a replacement variable which you can reference as {html}