The Salesforce Marketing Cloud platform comes with three powerful scripting languages that enable users to build out custom functionality for content, channels, messages, and more. This first-in-a-series blog post will introduce you to the primary language, AMPscript, and discuss how to use it to access data from Marketing Cloud when building a dynamic email.
What are Marketing Cloud’s scripting languages?
Marketing Cloud offers three scripting languages:
Depending on what you want to build and your level of expertise with software development, you can use all of them, just one, or even combine them. The official documentation provides a good overview of each of the languages and their applicable use cases. For this blog post, we’ll focus on AMPscript.
What is AMPscript?
To quote the documentation:
AMPscript is a scripting language that you can embed within HTML emails, text emails, landing pages, SMS messages, and push notifications from MobilePush.
There are a couple of things to unpack here.
- AMPscript is a scripting language. This means that it provides language elements that you may know from other programming languages, such as variables, constants, conditional checks using
if/else, or loop iteration using
FOR. Additionally, it offers built-in features, such as modifying data within Marketing Cloud, content personalization, or impression tracking.
- With AMPscript you can directly modify the structure of the client-side HTML structure (known as DOM = Document Object Model). This is a key difference from SSJS, which runs server-side and does not allow you to modify the DOM client-side.
And if many of these words sound as Greek to you — no worries, we’ll cover them, and more, in the video linked at the end of this post.
What is a dynamic email?
Whenever you receive an email from a vendor, chances are high that the email has been sent via Marketing Cloud. Just remember the last email you received; it had at least (hopefully) a personalized greeting. It may have also contained a list of your last purchases, highlighted your chances to join a loyalty program based on your current status, or offered you a coupon for your next purchase.
That email may have also tracked how often you opened it, on which links you clicked, and submitted all that information back to Marketing Cloud.
All of that, and more, makes a dynamic email. And that’s what we’ll build out.
Where do I get data for the dynamic email?
All data in Marketing Cloud is stored in so-called data extensions. A data extension represents a table in a SQL (not SOQL) database. And if you’re not familiar with databases, think of a data extension as a big spreadsheet. You can create as many data extensions as you need, such as one for email subscribers, another one for text translations, or one for coupon codes. A data extension allows you to structure basically any kind of data that you can think of as needed.
The data in a data extension can come from many different places. This can be a Salesforce org environment, Amazon S3 buckets, or files on an FTP server. You can also use the Marketing Cloud APIs to interact with the data in your data extensions. All of those options combined give you great flexibility to import, tailor, and extract Marketing Cloud data based on your organization’s requirements.
As we want to build a dynamic email, we have to differentiate between two categories of data extensions: sendable and non-sendable. All data extensions that contain data with a send relationship to a subscriber (think: the email recipient in our case) are sendable. All data extensions that don’t have such a relationship, like a product table or a list of your physical retail stores, are non-sendable.
Learn more about data extensions
Want to see what that looks like in action? Check out the video to get a step-by-step walkthrough on how to set up a data extension that can be used in a dynamic email.
This is just the first instalment of a series focusing on AMPscript with the Marketing Cloud. Make sure to check out the video above, and to subscribe to the Salesforce Developer YouTube channel. You should also bookmark this YouTube playlist, which will contain all the videos from this new series. And if you prefer reading over watching, we will also publish adjacent blog posts. So no matter how you prefer to learn – there will be more to explore for you on how to build YOUR dynamic emails!
About the author