Docs, snippets and answers

A practical reference for Salesforce Marketing Cloud.

AMPscript, SSJS, SQL, Apex and Data Cloud explained with code that runs. Written by a developer who uses it in production.

AMPscript
%%[
SET @email = AttributeValue("EmailAddress")
SET @name  = Lookup("Customers", "FirstName",
                    "Email", @email)
IF Empty(@name) THEN SET @name = "customer" ENDIF
]%%
Hello, %%=ProperCase(@name)=%%!
SQL
SELECT SubscriberKey, EmailAddress, CreatedDate
FROM (
  SELECT *,
    ROW_NUMBER() OVER (
      PARTITION BY EmailAddress
      ORDER BY CreatedDate DESC
    ) AS rn
  FROM Leads_Import
) AS t
WHERE t.rn = 1
SSJS
<script runat="server">
Platform.Load("Core", "1.1.1");
try {
  var de = DataExtension.Init("Leads_Import");
  var rows = de.Rows.Retrieve({
    Property: "Status",
    SimpleOperator: "equals",
    Value: "new"
  });
  Write(Stringify(rows.length));
} catch (e) {
  Write(Stringify(e));
}
</script>

Belts

Every piece of content has a belt: it tells you how much you need to know first.

How belts work →
  1. WhiteFirst contact
  2. YellowFirst implementations
  3. GreenDay-to-day autonomy
  4. BrownIntegrations
  5. BlackArchitecture

Changelog

Recently published

Recently published
Date Title Type Platform Belt Reading
Transactional Messaging API: real-time transactional email in Marketing Cloud Tutorial Marketing Cloud Engagement Brown 3 min
Marketing Cloud REST API: OAuth 2.0 authentication and writing to a Data Extension Tutorial Marketing Cloud Engagement Brown 3 min
Deduplicate records with ROW_NUMBER() in a Query Activity Snippet Marketing Cloud Engagement Green 2 min
Data Views in SQL: who opened or clicked in the last 30 days Tutorial Marketing Cloud Engagement Green 3 min
How to use LookupRows in AMPscript (and when to switch to Lookup or LookupOrderedRows) Tutorial Marketing Cloud Engagement Yellow 3 min
AttributeValue and empty fields: AMPscript personalization that never breaks a send Tutorial Marketing Cloud Engagement White 3 min

Who writes it

A developer, not an agency.

SF Dojo is written by one person who works with Marketing Cloud every day: AMPscript, SSJS, SQL, Salesforce integrations and, now, Data Cloud.

When a question does not fit in a tutorial: Describe my scenario

Meet the author →