Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Get to Know Our Programmatic Languages

Learning Objectives

After completing this unit, you'll be able to:

  • Identify each programmatic language available for Marketing Cloud Engagement.
  • Select the most appropriate language for your needs.

Introduction

Marketing Cloud Engagement offers a ton of functionality to both users who prefer drag-and-drop interactions and those who like to customize their interactions a little more. Maybe you need to personalize content or create data extensions to contain content coming in from outside sources. Marketing Cloud Engagement offers three distinct programmatic languages for use with messaging, data management, and other account-related activities. Use these languages to more dynamically access data and actions within messages, landing pages, and other resources. Instead of sending the same email content to every subscriber, you can personalize the message with content based on previous purchases, subscriber location, or other details.

Let's learn some names for these programmatic languages and get to know what benefits they offer.

  • AMPscript
  • Server-Side JavaScript
  • Guide Template Language

All of these options provide benefits depending on what you're trying to accomplish, so it's time to learn more about them.

AMPscript

AMPscript is Marketing Cloud Engagement's proprietary scripting language, available for use in email messages, landing pages, SMS messages, and push messages. From simple personalization to moving around larger amounts of data, AMPscript can handle the task. Because AMPscript can interact with almost every facet of Marketing Cloud Engagement, it's a good general-purpose tool to accomplish tasks within messages or landing pages. For example, you can include simple requests like the date and time of a send in your message.

%%=Now()=%%

You can also manipulate text contained within a variable for your message.

%%=LOWERCASE(@text)=%%

AMPscript also handles more complex operations, like looking up information in data extensions. This example shows how AMPscript looks up rows in the ZipCode data extension where the HomeCity value appears in the City field.

%%=LookupRows('ZipCode','City',HomeCity)=%%
Note

Check out the Marketing Cloud Engagement Contact Management module to learn more about data extensions.

These examples show just a small part of what you can accomplish with AMPscript. This language allows you to manipulate data within most facets of Marketing Cloud Engagement activities.

Server-Side JavaScript

AMPScript is a robust programming language, but we also know that developers appreciate something a little more familiar. That's where server-side JavaScript (SSJS) comes in. If you're familiar with web development, SSJS bears a striking resemblance to languages you've already used. Here’s a simple example.

var currentTime = Now();

Now, take a look at a more complex example for retrieving rows from a data extension related to a contact and writing them to an email message. 

<script runat="server">
   var dataRows = Platform.Function.LookupRows('CustomerData',['FirstName','LastName'],['Angela','Cruz']);
      if(dataRows && dataRows.length > 0) {
         for(var i=0; i<dataRows.length; i++) {
            Platform.Response.Write(dataRows[i]["Email"]);
         }
      }
</script>

Looks familiar, right?

Here are a few more things to remember about SSJS.

  • You can use arrays in your server-side JavaScript.
  • You can use more advanced exception handling with server-side JavaScript.
  • You can't interact with the DOM using SSJS—all functions execute within the applicable message or landing page.

Finally, note that SSJS comes in two libraries.

  1. Platform—use this library for messaging and other Marketing Cloud Engagement applications.
  2. Core—use this library only for Marketing Cloud Engagement landing pages and applications.

Guide Template Language

Marketing Cloud Engagement's newest programmatic language is Guide Template Language (GTL). If you've used Handlebar- or Moustache-style syntax before, you’ll have a good start on understanding GTL. GTL helps you create templates using JSON data that can populate entire messages or landing pages with data from your account's data extensions. It can also accept data from a script or REST API request.

Now that you've received a quick introduction to the Marketing Cloud Engagement’s programmatic languages, let’s dig deeper into each one.

Resources

Compartilhe seu feedback do Trailhead usando a Ajuda do Salesforce.

Queremos saber sobre sua experiência com o Trailhead. Agora você pode acessar o novo formulário de feedback, a qualquer momento, no site Ajuda do Salesforce.

Saiba mais Continue compartilhando feedback