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.