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.
%%[
SET @email = AttributeValue("EmailAddress")
SET @name = Lookup("Customers", "FirstName",
"Email", @email)
IF Empty(@name) THEN SET @name = "customer" ENDIF
]%%
Hello, %%=ProperCase(@name)=%%!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<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 →Index
By platform
- MCEMarketing Cloud EngagementEmail Studio, Journey Builder, Automation Studio, CloudPages, AMPscript, SSJS and SQL.6 items
- MCNMarketing Cloud NextThe new generation of Marketing Cloud, native to the Salesforce platform and Data Cloud.coming soon
- DCData CloudIngestion, harmonization, segments and activations with unified data.coming soon
- SFSalesforce PlatformApex, Flows and integrations between Sales/Service Cloud and Marketing Cloud.coming soon
Changelog
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 |