Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Snippet entry
How-to guide

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.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated Jun 16, 2026

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Mandatory fields
Block typerequired

Choose the Code Snippet block, not the HTML content block, so your code is stored verbatim without injected wrappers.

Snippet namerequired

A unique, descriptive name. AMPscript and the editor locate the snippet by this name and its folder path.

Folder locationrequired

The Content Builder folder where the snippet is saved, which forms part of the content path used by ContentBlockByName.

Gotchas
  • 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.

See the full Snippet entry

Snippet includes the definition, worked example, deep dive, related terms, and a quiz.