Where AMPscript, SSJS and JavaScript Can Be Saved
Which Content Builder and CloudPages types keep AMPscript, SSJS and client-side JavaScript on save, by API and in the editor, tested live on Engagement.
You paste code into an email, a content block or a CloudPage and press Save. The save succeeds, but is your code still there? Marketing Cloud Engagement removes some code without telling you. This page shows, for each content type, which kinds of code survive a save. It covers saving through the REST API and saving in the editor.
Only what gets stored. Whether the code runs when an email is sent or a page is published is a separate question and is not covered here. All results come from a live test on one business unit on 26 November 2026.
The short answer
- AMPscript is kept. All three forms are stored unchanged in every type tested, by API and in every code editor: the
%%[ … ]%%block, the%%= … =%%inline form and<script runat="server" language="ampscript">. The one exception is typing into a rich text editor (see the last point). - SSJS is kept.
<script runat="server">is stored unchanged in every type tested, by API and in every code editor, with the same rich text exception. - A client-side
<script>is removed. Plain<script>…</script>disappears from emails, content blocks and templates. The save still reports success. No error, no warning. - Landing pages keep everything, including a client-side
<script>. - CloudPages code resources depend on how you save. In the CloudPages editor a client-side
<script>is kept. Through the API the same text is removed. - Rich text editors turn tags into text. If you type
<script …>into the Content tab of a free form or text block, it is stored as escaped text (<script…), so it never runs. AMPscript in%%delimiters is not affected.
Results
kept stored unchanged · escaped stored as plain text (< instead of <) · removed stored without the snippet, save reported success
One chip means saving by API and saving in the editor gave the same result. Where they differ, the cell shows both, labelled API and Editor. Types with two editors get one row per editor.
| Type | Editor | A1AMPscript block | A2AMPscript inline | A3AMPscript script tag | S1SSJS | J1Client-side JavaScript |
|---|---|---|---|---|---|---|
| Emails | ||||||
HTML emailhtmlemail |
Code view | kept | kept | kept | kept | removed |
Template-based emailtemplatebasedemailVia API, the snippets were sent as an HTML block inside a slot. |
HTML block in a slotThe empty block was put into the slot by API, as a drag and drop could not be automated; the snippets were then saved in the email editor. | kept | kept | kept | kept | removed |
Text-only emailtextonlyemail |
Text editor | kept | kept | kept | kept | removed |
| Content blocks | ||||||
HTML blockhtmlblock |
Code editor | kept | kept | kept | kept | removed |
Code snippetcodesnippetblock |
Code editor | kept | kept | kept | kept | removed |
Free form blockfreeformblock |
HTML Editor tab | kept | kept | kept | kept | removed |
| Content tab (rich text, typed) | kept | kept | APIkeptEditorescaped | APIkeptEditorescaped | APIremovedEditorescaped | |
Text blocktextblock |
HTML Editor tab | kept | kept | kept | kept | removed |
| Content tab (rich text, typed) | kept | kept | APIkeptEditorescaped | APIkeptEditorescaped | APIremovedEditorescaped | |
| Templates | ||||||
Email templatetemplate |
Code editor (Paste HTML) | kept | kept | kept | kept | removed |
| CloudPages | ||||||
Landing pagewebpage |
Code View | kept | kept | kept | kept | kept |
JavaScript code resourcejscoderesource |
Code resource editor | kept | kept | kept | kept | APIremovedEditorkept |
CSS code resourcecsscoderesource |
Code resource editor | kept | kept | kept | kept | APIremovedEditorkept |
JSON code resourcejsoncoderesource |
Code resource editor | kept | kept | kept | kept | APIremovedEditorkept |
Text code resourcetextcoderesource |
Code resource editor | kept | kept | kept | kept | APIremovedEditorkept |
XML code resourcexmlcoderesource |
Code resource editor | kept | kept | kept | kept | APIremovedEditorkept |
RSS code resourcersscoderesource |
Code resource editor | kept | kept | kept | kept | APIremovedEditorkept |
The column headers stand for these five snippets. Each was saved on its own, between a line PROBE_START and a line PROBE_END:
| What it is | Snippet | |
|---|---|---|
| A1 | AMPscript block | %%[ SET @p = "A1" ]%% |
| A2 | AMPscript inline | %%="A2"=%% |
| A3 | AMPscript script tag | <script runat="server" language="ampscript">SET @p = "A3"</script> |
| S1 | SSJS | <script runat="server">Platform.Load("core","1");Write("S1");</script> |
| J1 | Client-side JavaScript | <script>console.log("J1");</script> |
What the results mean
Client-side JavaScript is removed without a warning
In emails, content blocks and templates, a <script> without runat="server" is cut out on save, together with its content. Everything around it stays. The API answers 201 Created or 200 OK as usual, and the editor shows “Saved”.
In the code snippet editor, the <script> was still visible after the save while the stored item no longer had it. You only see that it is gone when you open the item again. Use this check if a tracking snippet or widget “stopped working” after an edit.
The filter does not depend on the content type you send. Code resources created by API with the content type the CloudPages editor uses (application/javascript and so on) lose the tag just the same, and an update (PATCH) is filtered like a create.
Landing pages keep everything
A CloudPages landing page stores all five snippets unchanged, whether you save it in the editor or by API. This is the place for client-side JavaScript.
CloudPages code resources: the editor keeps what the API removes
Saved in the CloudPages editor, all six code resource types keep a client-side <script>. Created or updated through the REST API, the same text is removed.
Watching the stored item once per second during an editor save hints at why the two differ. For the CSS, JSON and RSS resources, a version without the <script> was stored first, and about a second later the full text, which stays. For the other three types only the final version was caught.
So if you deploy code resources by API, for example with a deployment tool, any <script> tag inside them is lost. The normal content of a JavaScript code resource is plain JavaScript without a <script> tag, and that case was not part of this test.
Rich text editors store tags as text
The Content tab of a free form block or text block is a rich text editor. Text you type there is text, so <script runat="server"> becomes <script runat="server">…. It is kept, but it no longer runs. AMPscript in %%[ … ]%% and %%= … =%% has no tags and is stored as typed.
To add a script tag to these blocks, use their HTML Editor tab. There the results are the same as for an HTML block.
How this was tested
- Where: a child business unit used for testing, Marketing Cloud Engagement, 26 November 2026.
- By API: for every type, one new asset per snippet, created with
POST /asset/v1/content/assets, plus one control asset holding only the two marker lines. Every control was stored as sent, so a removed snippet is never a type that failed to save. The code resources were created twice, once without and once with the content type the CloudPages editor sets. - In the editor: one item per type and editor, created in Content Builder or CloudPages, re-used for the five snippets. The code was pasted into code editors and typed into rich text editors and the CloudPages editor, then saved with the Save button.
- Reading back: after every save, the stored item was read through the REST API and the text between the markers compared with what was sent (line endings ignored). For CloudPages code resources the item was read once per second during the save.
- Not tested: whether the code runs when an email is sent or a page is published, and a JavaScript code resource with plain JavaScript (no
<script>tag). - Browser extensions: an extension that rewrites or formats editor content on save can change what gets stored. Format-on-save features were switched off for the test.
More metadata types will be added to this page over time.
Related
- Where SSJS and JavaScript can be saved on ssjs.guide: the SSJS and JavaScript columns only
- ssjs.guide for the SSJS reference
- Personalization strings, AMPscript & SSJS together
- Querying Data Extensions with AMPscript