Salesforce Marketing Cloud

Server-Side JavaScript
Reference Guide

Everything you need to write, debug, and master SSJS in SFMC — global functions, Platform APIs, Core library, WSProxy, HTTP, engine limitations, and real-world recipes.

Reference
Guides
Quick Start

A minimal SSJS CloudPage:

<script runat="server">
Platform.Load("core", "1.1.5");

try {
    var subscriberKey = Platform.Request.GetQueryStringParameter("sk");

    if (subscriberKey) {
        var email = Platform.Function.Lookup(
            "Subscribers",
            "EmailAddress",
            "SubscriberKey",
            subscriberKey
        );
        Write("<p>Hello, " + email + "</p>");
    }
} catch (e) {
    Write("<p>Error: " + Stringify(e) + "</p>");
}
</script>

Key points:

  • SSJS runs on the server inside <script runat="server"> blocks
  • Platform.Load("core", "1.1.5") must be called before using Core library objects
  • The engine is roughly ES3/5 — no arrow functions, let/const, template literals, or async/await
  • Use Write() to output HTML, Stringify() to serialize objects, Platform.Function.ParseJSON() instead of JSON.parse()

Read the full Getting Started guide