Previewing a Template With Sample Data

January 26, 2018

Use sample data in the Dyspatch Editor to power dynamic email contentDynamic Email ContentText, links, images, and any other email elements that can change, through programming logic, based on the end user. in your template previews. Sample data is formatted as a JSON object, similar to what your system uses when passing data to a template for rendering.

What is JSON?

JSON is a format for representing data with key and value pairs, used to store and exchange data. A JSON key has to be text wrapped in double quotes (e.g. "firstName") and a JSON value can be text, numbers, lists, etc.

An Example JSON Object

Below is an example of a JSON object, with some values: a string "Kieran", a number 2, a list of strings ["sushi","pizza","hash browns"] and a boolean true.

{
  "firstName": "Kieran",  
  "pets": 2, 
  "favFood": ["sushi","pizza","hash browns"], 
  "nicePerson": true 
}

A Template Without Sample Data

A template without sample data

Without sample data, variables will appear in the preview just as they are in your template code like the {{ teamName }} above.

Adding Sample Data

Adding in Sample Data

Navigate to the Sample Data tab within the editor to add sample data for your template. Using JSON format, create your sample data. Variables in your template will now be replaced with the values provided by the sample data.

Sample Data Errors

Sample data error

Incorrect formatting of sample data will cause a warning to appear in your Preview Pane, with a description and location of the error. The error in the example above, "Expecting ':' delimiter: line 2 column 14 (char 15)," means the sample data is missing the colon : required to separate the key from its value.

Where is Sample Data Used?

Sample data is used in the Dyspatch Editor Preview Pane, for Device PreviewsDevice PreviewsPreview an email template on a variety of email clients to make sure template code is working as intended. and test sending.

Sample data is only for previewing in Dyspatch and will not be used in your live emails.

Didn't find what you're looking for?

Ask our support team, we're here to help!

Contact Support