This FAQ provides answers to questions you may have about snippets.
In this article
- How do I add a snippet to a template?
- What kinds of content can a snippet contain?
- Can I copy a snippet from one project to a different project?
- Can I export the HTML from a snippet?
- Can I see performance data for my snippets, like how many users saw a particular snippet?
- I'm having trouble with HTML tags in my snippets. What should I do?
- Can I nest snippets inside each other?
- Can I use Catalog and Collections in my snippets?
- Can I use Handlebars to reference user profile and event data in snippets?
- What happens when I delete a snippet?
- Can I recover a deleted snippet?
- How do I style a snippet?
How do I add a snippet to a template?
See Adding a Snippet to a Template.
What kinds of content can a snippet contain?
Text, HTML (including image tags that reference hosted images), CSS style
attributes (but not <style>
tags), Handlebars expression, and data feed
references,
Can I copy a snippet from one project to a different project?
Yes, you can! When you make a copy of the snippet, select Copy to: Another project and select the project you want to copy the snippet to.
Keep in mind:
Your snippet name has to be unique in each project. If there's already a snippet with the same name in the project you're trying to copy to, you'll need to change your snippet's name before you can copy it to the new project.
If your snippet contains nested snippets, the nested snippets won't automatically be copied when you duplicate the parent snippet. You'll need to copy those separately.
Can I export the HTML from a snippet?
You can copy and paste the HTML from a snippet. To access its HTML in the WYSIWYG editor, toggle to Source mode.
Can I see performance data for my snippets, like how many users saw a particular snippet?
Not at this time.
I'm having trouble with HTML tags in my snippets. What should I do?
A few things to consider:
Some message fields (like Subject Line, Preheader Text, and SMS) aren't compatible with HTML.
If you're seeing unwanted HTML, open the snippet from the Snippets page, switch to Source mode in the WYSIWYG editor, and find and remove any unwanted HTML tags.
Additionally, make sure that the snippet expression you've placed in your template uses the appropriate number of curly braces:
If you want the snippet to render any HTML tags found in its content as actual HTML (so they affect styles, etc.), your snippet expression should use triple curly braces (for example,
{{{ snippet "My_Snippet" }}}
).On the other hand, if you want HTML tags to render as text (so that the tags themselves appear in your message content), your snippet expression should use double curly braces (for example,
{{ snippet "My_Snippet" }}
).
Can I nest snippets inside each other?
Yes, you can. However, be careful and test thoroughly. Nested snippets take longer to render, and in some cases they may cause timeouts or send skips.
Also, remember that a snippet cannot reference itself.
Can I use Catalog and Collections in my snippets?
Yes, but be careful and test thoroughly. Large/complex collections can increase the time it takes to render a snippet, and in some cases they may cause timeouts or send skips.
Can I use Handlebars to reference user profile and event data in snippets?
Yes, you can. However, when you add dynamic logic to a snippet, it's a good idea to test thoroughly and preview your template with data to make sure that everything works as expected.
Also, when referencing user profile fields, remember that some users may not have the referenced field. To prevent the snippet from rendering blank space in these cases, it's a good idea to provide a fallback option (so that at least something displays, even if it's not highly personalized content).
Keep in mind that particularly complex logic, like referencing lots of user profile or custom event data, can increase template rendering times. In some cases, this may result in timeouts or send skips.
What happens when I delete a snippet?
Before deleting a snippet, remove it from all of the templates and campaigns that reference it. Any recurring, triggered, or journey campaigns that reference a deleted snippet will show an error and stop sending until you update their templates.
However, it can sometimes take several hours for Iterable to fully delete a snippet. In the meantime, campaigns that reference it will continue to send, but without the snippet content.
Can I recover a deleted snippet?
Unfortunately, no. Once you delete a snippet, it's gone for good. Before deleting a snippet, make sure you really don't need it anymore, or create a backup copy.
How do I style a snippet?
As you build a snippet, test it with different templates to make sure that its styles appear as you'd like.
Some things to consider:
In cases where a template needs complete control over the styles of the content rendered by a snippet, it's probably best not to use the snippet, and to instead add the snippet's content directly into the template. You could potentially modify the styles of the snippet itself, but that would affect all templates that rely on the snippet, which may not be preferable.
Even if you add styles to a snippet expression that you've placed in a template editor, the styles contained in the snippet definition itself can still win out. Don't assume that applying a style to a snippet expression (in any editor) will necessarily get you the output that you expect.
-
It is sometimes possible to use HTML code to override the styles contained in a snippet definition:
- In the Drag and Drop editor, if you place a snippet expression in an HTML block (rather than a Text block), you can add additional HTML to the HTML block's Content Properties pane.
- In the WYSIWYG editor, you can add HTML to the Source pane.
- In the Side by Side editor, you can edit the HTML directly.
In all cases, testing is the name of the game. Use Preview with Data and send proofs of your templates, with various user profiles, before sending or activating a campaign.