# Merge fields in the Interactive editor

Add merge fields, conditionals, and looping fields in the Interactive editor.

You can add [Merge Fields](https://www.airship.com/docs/reference/glossary/#merge_field) when using the drag-and-drop option in the Interactive editor.

When you create a merge field, you set its field logic, which determines both how you use the field and the options you have when you use the field in a message: 

* **None** applies to **Text content** elements. When you send a message, Airship replaces your merge field with the appropriate value. This is considered a standard merge field.

* **Conditional** applies to **rows of content** in your message. When you send a message, Airship evaluates the condition and determines whether or not to insert a row of content, depending on if the **Key Path** is populated (true) or not (false).

* **Loop** applies to **rows of content** in your message. When you send a message, Airship evaluates the condition and determines whether or not to repeat a row of content for *each* item in an array, or display the content, depending on whether or not an array is populated. Loop is not supported for [In-App Automation](https://www.airship.com/docs/reference/glossary/#iaa).

Merge fields, conditionals, and looping fields make it easier to take advantage of [Dynamic Content](https://www.airship.com/docs/reference/glossary/#dynamic_content). Merge fields are not supported for [Email Preference Centers](https://www.airship.com/docs/reference/glossary/#preference_center).

> **Tip:** You can also take advantage of looping (`#each`), conditional (`#if`), and other advanced [Handlebars](https://www.airship.com/docs/reference/glossary/#handlebars) within HTML content to show or repeat text. However, you cannot apply conditional or looping logic to block-level elements in your layout without adding merge fields to your layout.


## Creating and editing merge fields

Create or edit merge fields when editing layouts:

![Editing a merge field](https://www.airship.com/docs/images/interactive-merge-field_hu_cce8fb714d607322.webp)

*Editing a merge field*

1. Select **Merge fields** in the header of the editor.

1. Select **Create field** to add a new field or the edit icon (
) to edit an existing field.

1. Enter a **Field Name**. This is the name you'll see in the editor.

1. Enter the **Key Path**. This is the path to the variable that you want to use.
   * For [Attributes](https://www.airship.com/docs/reference/glossary/#attributes), use the attribute name.
   * For [Custom Event](https://www.airship.com/docs/reference/glossary/#custom_event) properties, use JSON notation for the property in the event's `properties` object that you want to use. For example, if you wanted to access `properties.name` from your custom event, you would enter `name`.
   * For a [Create and Send](https://www.airship.com/docs/reference/glossary/#create_and_send) CSV, use the column name for your variable.

1. Make a selection for **Field Logic**

1. Select **Save**.

1. Select **Done 
** to return to the editor.

## Using merge fields

The way you use a merge field depends on its logic: None, Conditional, or Loop.

### None

![Using a standard merge field](https://www.airship.com/docs/images/insert-merge-field_hu_1659516f01cf042a.webp)

*Using a standard merge field*

You can insert merge fields set to None into any Text content element, and Airship will add your merge field with the correct syntax in your text:

1. Select the Text content element that you want to add a merge field to, and a toolbar will appear.
1. Select **Merge Tags** from the toolbar, and select a merge field.

### Conditional and Loop

Merge fields set to Conditional and Loop apply to a row. You use the merge field to determine whether you want to show, hide, or repeat the entire Text content element.

While conditions apply at the row level, you can still use merge fields within your conditional block. If you want to use a field both as a block-level condition and as a value within a block, you should save two merge fields: one to represent the conditional usage of the field, and one with field logic set to None.

When you apply a looping merge field to a content block, you can reference the current instance of the loop with the `this` context. For example, if looping through an array of products in your audience's shopping cart, you might reference the price for each product in the loop with `{{this.price}}`.

To set conditional or looping logic:

1. Select the row you want to apply the logic to and select **Merge Tags 
**.
   ![Selecting the Merge Tags option in the Interactive editor](https://www.airship.com/docs/images/merge-tag_hu_6cef51c5d87a680d.webp)
   
   *Selecting the Merge Tags option in the Interactive editor*

1. Select a merge field and select from the available options:
   
   **Conditional**
   * **Show if condition is false** — Displays the block if the field does not exist, is empty, or is `null`.
   * **Show if condition is true** — Displays the block if the field exists and is not an empty string or `null` value.
   
   **Looping**
   * **Repeat for each** — Repeats the block for each item in an array.
   * **Show if there are none** — Displays the block if the key path is empty or does not exist.
   * **Show if there are any** — Displays the block if the key path exists and has at least one item in the array.

1. Choose **Select**.

![Using a merge field with conditional logic](https://www.airship.com/docs/images/insert-conditional-merge_hu_c8e99069542744d5.webp)

*Using a merge field with conditional logic*
