Snippet
A Snippet in Salesforce Marketing Cloud Engagement is a reusable block of content you build once in Content Builder and reference in many emails, templates, landing pages, and mobile messages.
Definition
A Snippet in Salesforce Marketing Cloud Engagement is a reusable block of content you build once in Content Builder and reference in many emails, templates, landing pages, and mobile messages. In the Content Builder editor it appears as the Code Snippet block type, which holds custom HTML and AMPscript that you save to your content library and drop into any message.
The point of a snippet is one source of truth for repeated content. A legal disclaimer, a header, a footer, or a preference-center link lives in a single snippet, and every message that references it shows the current saved version. Update the snippet once and the change reaches everywhere it is used, so you never hand-edit dozens of emails.
How Snippets work inside Content Builder
Snippet versus the HTML content block
People often confuse a Code Snippet with the HTML content block, and the difference matters. An HTML content block lets you paste markup, but the editor can wrap that markup in extra table and div code so it renders cleanly inside the email layout. That is fine for a one-off section. It is a problem when your snippet is itself a fragment of code that must stay exactly as written, like an AMPscript routine or a tracking pixel. The official guidance is direct: HTML content blocks can add extra code wrappers to your message, so to preserve your code, use code snippets instead. A snippet stores your code verbatim and outputs it without injecting wrappers. That makes snippets the right home for AMPscript blocks, conditional logic, custom unsubscribe markup, and any HTML where a stray wrapper would break the layout. When you need pixel-level control over what ships, reach for a snippet, not the HTML block. When you just need a styled paragraph or image, the standard blocks are simpler.
Creating and saving a snippet
You make a snippet in one of two ways. You can add a Code Snippet block to a message from the block palette and write or paste your code into it. Or you can take code you already wrote in the editor, select it, right-click, and choose Create Code Snippet to lift that fragment into a reusable block. Either path saves the snippet into Content Builder, where it lives in a folder alongside your images, templates, and other blocks. Content Builder is the cross-channel content store for Marketing Cloud Engagement, so a snippet saved there is available to email, templates, landing pages, and mobile messages from one place. Content Builder also ships system snippets, which are standard snippets included out of the box that you can search for and reuse rather than writing common patterns yourself. Once saved, your snippet has a name and a folder path. That name is how you locate it in the editor and, importantly, how you reference it from AMPscript later.
Referencing a snippet with AMPscript
Snippets are not limited to drag-and-drop. You can pull one into an email programmatically with the AMPscript function ContentBlockByName, which returns the content of a block by its full content path. The syntax looks like %%=ContentBlockByName("Content Builder\Footer Disclaimer")=%%, and Marketing Cloud inserts the saved snippet at that spot when the email renders. A companion function, ContentBlockById, does the same by ID rather than name. Both functions accept a fallback message and a status code, so if the block is missing or fails to load you can show backup content instead of breaking the send. There is a quiet benefit here too: content referenced by ContentBlockByName is automatically included when you package and move assets between business units or environments, which keeps deployments consistent. In Marketing Cloud Next these functions read from the Marketing Content Management System and return the most recently published version when several exist. This is what turns a snippet from a copy-paste shortcut into a genuine shared building block.
Why one source of truth changes operations
The operational case for snippets is simple math. Picture a sending program with two hundred active emails that all carry the same legal footer. A regulator asks you to change one line. Without snippets, that is two hundred manual edits, two hundred chances to fat-finger the markup, and a long QA cycle. With the footer stored as one snippet, you edit it once and every email that references it now shows the corrected text. The latest saved version of a block appears on the canvas and in preview whether or not it is formally published, so authors always see current content while they build. This is content hygiene, the same discipline that keeps brand colors and contact details accurate across a large library. Snippets reduce drift, the slow divergence where copies of the same content fall out of sync over months. They also speed up authoring, because a marketer assembles a message from trusted parts instead of rebuilding boilerplate each time. For high-volume programs, snippets are less a convenience and more a control on quality and risk.
Limits and gotchas worth knowing
Snippets are powerful but not unconditional. Reusable content blocks cannot contain dynamic content in the targeting-rule sense, so you do not build audience branching inside the block itself. For conditional output you write AMPscript inside the snippet or wrap the reference in logic in the parent message. Naming and folder structure also matter more than they first appear. Because AMPscript references a snippet by its exact content path, renaming or moving a snippet can break every message that calls it by the old path. Treat snippet names as a small contract. A second gotcha is the wrapper behavior already noted: if you store fragile code in an HTML block instead of a snippet, the injected markup can corrupt your output, and the failure is easy to miss until a test render. Finally, remember that a snippet update is global by design. That is the feature, but it means a careless edit propagates instantly, so changes to widely used snippets deserve a review step before they ship to live sends.
Where snippets fit in a content strategy
Think of snippets as the lowest reusable layer in Content Builder. Above them sit content blocks, then layouts, which are saved groups of blocks, then full templates. A mature program decides early what belongs at each layer. Truly atomic, repeated fragments such as disclaimers, preheader text, social-follow markup, and AMPscript helpers become snippets. Visual sections that combine an image, text, and a button become layouts. The skeleton of the message becomes a template. Drawing those lines keeps the library tidy and makes governance possible, because you know exactly where a given piece of shared content is defined. Snippets also pair naturally with personalization. You can hold a personalization-string block or an AMPscript lookup in a snippet and reuse the same logic across campaigns, which means your personalization behaves consistently instead of being re-implemented per email. The payoff is a content system where common pieces are defined once, referenced everywhere, and changed safely, which is exactly what high-volume marketing teams need to move fast without breaking brand or compliance.
Create a reusable Code Snippet in Content Builder
Build a reusable Code Snippet in Content Builder, then reference it across your emails. You create snippets inside the Content Builder editor in Marketing Cloud Engagement.
- Open Content Builder and start a message
In Marketing Cloud Engagement, go to Content Builder and open or create an email or template. The drag-and-drop editor is where Code Snippet blocks are added.
- Add a Code Snippet block
Drag the Code Snippet block from the palette onto the canvas, then paste or write your HTML and AMPscript. To reuse code you already wrote, select it in the editor, right-click, and choose Create Code Snippet.
- Name and save to a folder
Give the snippet a clear name and save it to a Content Builder folder. The name and folder path become the reference you will use later, so keep them stable and descriptive.
- Reference it where needed
Drag the saved snippet into other messages, or call it with AMPscript using %%=ContentBlockByName("path\name")=%% so the current version renders at send time.
Choose the Code Snippet block, not the HTML content block, so your code is stored verbatim without injected wrappers.
A unique, descriptive name. AMPscript and the editor locate the snippet by this name and its folder path.
The Content Builder folder where the snippet is saved, which forms part of the content path used by ContentBlockByName.
- Renaming or moving a snippet can break every message that references it by the old content path.
- Use a Code Snippet, not an HTML content block, for fragile code; the HTML block can add wrappers that alter your output.
- A snippet edit is global, so review changes to widely used snippets before they reach live sends.
Trust & references
Cross-checked against the following references.
Straight from the source - Salesforce's reference material on Snippet.
- Content BuilderSalesforce
- ContentBlockByName (AMPscript Content Functions)Salesforce
Hands-on resources to go deeper on Snippet.
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. What is a Snippet?
Q2. What's the key benefit?
Q3. What should be snippets?
Discussion
Loading discussion…