Snippets are reusable content blocks that you can add to your templates to make building and personalizing messages in Iterable even easier.
This article covers how to create, edit, and copy snippets in Iterable.
For an introduction to snippets and how they work, see Snippets Overview.
# In this article
# Required permissions
To create, edit, or delete a snippet, you'll need the Create and Manage Snippets project permission.
To manage your snippets, go to Content > Snippets.
# Creating a snippet
To create a new snippet:
- Go to Content > Snippets and click New Snippet.
- Give your snippet a name. You won't be able to change this later, so choose a unique, descriptive name.
- (Optional) Add a description to help your teammates understand the snippet's purpose.
- (Optional) Add variables so that you can customize the snippet's output from within a template.
- Add your snippet's content in the snippet editor.
- Click Save Snippet.
To follow along with a guided example, read Tutorial: Create Your First Snippet.
# Snippet editors
Iterable supports two editors for creating and editing snippet content:
-
Side by Side editor Always available in Iterable.
A text-based editor with full control over HTML and CSS. The best choice for plain text snippets or when you need precise control over your markup.
-
WYSIWYG editor Available when enabled in your project's settings.
A visual, rich text editor for creating and editing content without writing HTML directly.
# Choosing an editor
Which editor a snippet opens in depends on the snippet's content and your project settings:
If the WYSIWYG editor is disabled in your project settings, snippets always open in the Side by Side editor.
Snippets that contain HTML tags open in the WYSIWYG editor by default. Snippets without HTML tags open in the Side by Side editor.
NOTE
The WYSIWYG editor can add unexpected HTML tags to your content. To avoid this:
Edit plain text snippets in the Side by Side editor.
After editing in the WYSIWYG editor, verify your HTML in the Side by Side editor or the WYSIWYG editor's source view.
To learn more, read The WYSIWYG Editor.
# Switching editors
To switch editors, click the Switch To... button. Save your snippet before switching—unsaved changes are discarded when you change editors.
# Snippet properties
When you create or edit a snippet, you'll work with the following properties.
# Name
Give each snippet a unique, descriptive name—you'll reference this name in your templates as part of the snippet expression.
To help your team organize and collaborate on snippets, consider adopting a consistent naming convention. Snippet names are internal to your organization and won't be visible to users receiving campaigns.
Snippet names can include only:
- Letters (
a-z,A-Z) - Numbers (
0-9) - Spaces (
) - Dashes (
-) (Hyphen-minus, not en-dash or em-dash) - Underscores (
_)
Common errors:
- Unsupported characters. If a name includes unsupported characters, the name field shows an error and you won't be able to save until you fix it.
- Duplicate snippet names. If a name is already in use, Iterable shows an error when you try to save the snippet. You won't be able to save until you change the name to a unique one.
IMPORTANT
Once you save a snippet, you can't change its name.
# Description
An optional internal field to help your teammates understand the snippet's purpose. The description displays on the Snippets index page in the expandable section under the snippet's name.
# Content
A snippet's content is what gets inserted into any template that references it. For example, a snippet might contain a promotional banner, a list of product recommendations, or a message footer.
You can create snippet content using one of the snippet editors.
Snippets can include:
HTML (including images) — To include an image, reference one that's already hosted externally. Close your HTML tags, and remember that some channels (like SMS) can't render HTML.
-
CSS — Snippets support inline CSS on HTML tags (using the HTML
styleattribute). However,<style>tags are not supported.Standard precedence rules apply to CSS in a snippet:
- A more-specific selector takes precedence over a less-specific one.
- If two CSS rules have the same specificity, the one that appears later in the code takes precedence.
- A CSS rule with
!importantalways takes precedence.
NOTE
After adding a snippet to a template, test it to confirm styles appear as expected. Styles defined in the snippet affect every template that uses it, and styles applied to the snippet expression in the template editor may not always override the snippet's own styles. For detailed guidance on managing snippet styles—including how to override them from within the template editor—see How do I style a snippet?
-
Handlebars — To reference a user profile field, event field, or variable, use a
Handlebars expression. For example,
{{location}}or{{#if signedUp}}. To learn more, read Handlebars Overview.
- Data feeds — A snippet can reference data feeds. However, any templates that reference the snippet must be properly configured to use data feeds. To learn about passing data feed fields to a snippet as variables, read Using Data Feeds in Snippets.
Snippets cannot include:
-
<script>tags -
<iframe>tags - JavaScript
- References to themselves
# Variables
Variables are dynamic fields defined in a snippet that let individual templates customize the snippet's output. The snippet's content can then display the passed-in values, apply conditional logic, modify styles, and more. For example, a snippet might define variables for a CTA label, a button color, or a value to drive conditional logic in Handlebars.
Variables are positional parameters by default, meaning templates must pass values in the same order the variables are defined. However, you can also use named parameters, which allow templates to pass values in any order.
To learn more, see Customizing Snippets with Variables.
Variables also enable you to include data feed fields in a snippet. To learn more about this advanced use case, see Using Data Feeds in Snippets.
# Snippet expression (default value)
Iterable generates a basic expression when you create a snippet, which you can copy and paste into a template. This is a default value that you can modify to meet your needs when you add the snippet to a template.
The most basic snippet expression is:
This expression inserts the content of the snippet named snippet_name into the
template.
When a snippet has variables, the expression expands to include them in the order
they are defined in the snippet. For example, if a snippet has two variables,
variable1 and variable2, the default expression is:
Depending on your use case, you may need to modify the expression—for example, to pass variable values, include data feed fields, or add conditional logic.
To learn how to build and customize snippet expressions, see Adding a Snippet to a Template and Customizing Snippets with Variables.
# Editing a snippet
IMPORTANT
Editing a snippet can change active campaigns.
When you edit a snippet, any changes you make immediately affect every template that references it, even while campaigns are running.
Before editing, check whether the snippet is used in active campaigns. To learn how to check, read See Where Snippets Are Used.
Then, decide how you'll edit the snippet:
- Option 1: Edit the original snippet when you're making low-risk changes, such as updating the description, or when the snippet isn't used in active campaigns.
- Option 2: Copy and test before updating when you're changing user-facing content or variables on a snippet that is actively used.
NOTE
Snippet names can't be changed after creation. If you need a new name, make a copy of the snippet, update the name, and then update templates to reference it. Afterwards, you can delete the old snippet if it's no longer in use.
# Option 1: Edit the original snippet
This is the simplest option for making changes to a snippet. Changes take effect right away, and running campaigns start using the new version at the next send.
To edit a snippet directly:
- Go to Content > Snippets and find the snippet you want to modify.
- Click on the snippet's name to open it.
- Make your changes to the snippet.
- Click Save Snippet to save your changes.
# Option 2: Copy and test before updating
Use this option when a snippet is actively used and your changes affect what users see (for example, content or variables). The workflow is: copy, test, then apply to the original.
To safely edit a snippet:
- Go to Content > Snippets and open the snippet you want to modify.
- Without making any changes, click Save Snippet, then click Save As New in the menu that appears. Give the copy a name and click Save Snippet.
- Open the new copy and make your changes. Click Save Snippet to save them to the copy.
- Find a template that uses the snippet, and make a copy of that template using the instructions here to test your changes.
- Update the copied template to use the new snippet name instead of the original, preview it with data, and send proofs.
- If everything looks good, apply the same changes to the original snippet. Follow the edit flow above to update the original snippet, copying the changes over from the test version to the original.
- (Optional) Delete your test copy when you're done.
# Copying a snippet
To make a copy of a snippet:
- Go to Content > Snippets and find the snippet you want to copy.
- Click the three-dot menu for the snippet, then click Make a Copy.
- Choose whether to copy the snippet to the same project or a different one.
- If you're copying to a different project, select the destination project.
- If you're copying to the same project, leave the destination project as is.
- (Optional) Edit the new snippet's name.
- Click Copy Snippet.
# Deleting a snippet
To delete a snippet:
- Go to Content > Snippets and find the snippet you want to delete.
- Click the three-dot menu for the snippet, then click Delete Snippet.
- Click Delete Snippet in the confirmation modal.
# Troubleshooting
# Snippet changes aren't appearing in sent messages
If a snippet appears to render outdated content, the change may not have saved. Iterable does not auto-save snippet edits. After making changes, click Save Snippet to save them.
If the change was saved but is still not appearing, the template may be using a cached data feed response. Caching is set at the template level and can cause messages to use data that's up to one hour old. To learn more, see Cache data feed response (up to 1 hr).
# The WYSIWYG editor is adding unexpected HTML
The WYSIWYG editor can introduce extra HTML tags—such as <p> or <span>
tags—that interfere with the snippet's output. To remove them:
- Open the snippet in the WYSIWYG editor.
- Switch to Source mode to view the raw HTML.
- Find and remove any tags you didn't add.
To avoid this in the future, edit plain text snippets in the Side by Side editor.
# You need to rename a snippet
Snippet names can't be changed after a snippet is saved. To use a new name:
- Make a copy of the snippet.
- Give the copy the new name.
- Update your templates to reference the new snippet name.
- Delete the old snippet when it's no longer in use.
# A change to a snippet is affecting templates unexpectedly
When you save a snippet, the change immediately takes effect in every template and campaign that references it. Before editing an active snippet, check which templates use it—see See Where Snippets Are Used.
To make changes safely, create a copy of the snippet first, test the copy, then apply the changes to the original. For step-by-step instructions, see Editing a snippet: Copy and test before updating.
# Want to learn more?
For more information about some of the topics in this article, check out this Iterable Academy course. Iterable Academy is open to everyone — you don't need to be an Iterable customer!
Iterable Academy
Support docs