Introducing Snippets

Earlier this year, I shared a preview of Snippets—a great new feature in SparkPost’s email templating capabilities. Snippets are modular, reusable content that, once created, can be imported into the HTML, Text, or AMP part of any email template using our render_snippet  macro call.

Snippets make maintaining consistent content really efficient. One classic scenario is to make sure every email you send uses a standard footer, social share buttons, and the like. And there certainly are many more.

Experienced SparkPost users might notice that Snippets play a similar role to the dynamic_html  and dynamic_plain  functions of SparkPost templates, with a key difference: snippets are created and stored ahead of time, rather than passed inline within a transmissions request.

Today, we’re releasing the Snippets feature. The next time you log into SparkPost, you’ll find Snippets located at the bottom of the app’s primary navigation menu. (And by the way, the Snippets API endpoint can also be used to create snippets via the command line or code.)

Getting Started with Snippets in 3.. 2.. 1..

Here’s a quick walk-through of how to get started with Snippets.

Snippets are built into SparkPost templates and transmissions; features you already use today. Here’s how it works:

Step One: Create a Snippet

First things first: let’s create a new snippet. In this example, a snippet is being used to add social media buttons to a stored email template. The social media snippet can be called across many templates, so updating the snippet with a new button or content, will update all templates that call that snippet in the future!

  • Once you’ve logged into SparkPost, click “Snippets” in the left navbar.
  • On the Snippets page, you’ll see a list of existing snippets, if any. Otherwise, you’ll see a blank slate. Let’s change that!
  • Let’s create a new snippet. Click on the button on the top right labeled “Create Snippet”.
  • Give your snippet a name. You’ll note that we automatically suggest a new snippet ID for you as well, but you’re welcome to override that with any unique ID text you wish.
  • We’ll leave the subaccount field alone for this tutorial.
  • Add in your HTML content and Text content as desired.
  • Click the “Create” button to save this new test and go to the next step.

Step Two: Add the Snippet Into Your Template

  • Click on “Templates” on the left navbar and pick any stored template you’d like to have a snippet added to.
  • Above the content editor, you’ll find a new button called “Import Snippet”. Begin to type in the name of your snippet, and the list below will immediately show you snippets you’ve created that match the letters typed.
  • Pick your snippet, and then click on “Copy” to copy the render snippet code you’ll need to insert into your template
  • Click on “Done”

  • Determine where in your template you’d like to add your snippet, and then simply paste the snippet code into your template.
  • Save the template.

Step Three: Send the Email!

Here is a comparison of the email rendered, before and after the snippet was added:



How Will You Use Snippets?

Snippets are one of those seemingly simple features that can completely change how you design and inject using SparkPost. Snippets provide more flexibility and creativity when sending email campaigns, and they dramatically reduce wasted time and energy spent maintaining and updating numerous templates. Bottom line, Snippets let you build more awesome emails!

As you experiment and leverage snippets, we’d love to hear about your experience, and in what unique ways you used them. In fact, your input and feedback will be an important part of how we continue to develop Snippets and other templating features. We’ve created a form that makes it easy to share your feedback with our product team — or Tweet us or give us a shout in our Community Slack!

— Isaac Kim
Technical Product Manager, SparkPost