Thursday, January 5, 2023
HomeMobile MarketingAMPScript: What Is AMPScript? Assets and Examples

AMPScript: What Is AMPScript? Assets and Examples


My agency is constructing out dynamic emails which might be pushed by choice pages in-built Cloud Pages utilizing AMPScript for a number of Advertising and marketing Cloud purchasers, most of whom are built-in with Salesforce as their CRM. After we start working with Advertising and marketing Cloud purchasers, we’re typically shocked that they’re not benefiting from this highly effective customization instrument to create focused and customized emails which might be way more partaking. Merely put, you’re probably not realizing your return on funding with Advertising and marketing Cloud if you happen to’re not deploying options that make the most of AMPScript.

What Is AMPScript?

AMPScript is a proprietary scripting language native to Salesforce Advertising and marketing Cloud that’s used to insert customized and dynamic content material into e mail messages, touchdown pages, and SMS messages.

There’s no documentation on why it’s referred to as AMPScript… though it could have been one thing like Automated Advertising and marketing Cloud Programming Script. And it’s to not be confused with Adobe’s Advertising and marketing Cloud Script, AMP.

What Are Some AMPScript Studying Assets?

  • Salesforce’s AMPScript Syntax Information – paperwork the right way to accurately type AMPscript perform calls, declare variables and values, and reference AMPscript key phrases.
  • Salesforce Trailhead AMPScript Unit – This module introduces you to the fundamentals of AMPscript, whereas additionally supplying you with the sources you have to dig deeper.
  • AMPScript.com – Jackson Chen is a former ExactTarget and Salesforce eMarketing Cloud worker who write this useful resource for customers to study AMPScript.
  • AMPScript Information – This complete reference handbook offers documentation on each AMPscript perform, with supporting code examples for real-world situations.
  • The Drip – This improbable weblog from Salesforce Ben offers some primary and superior finest practices and code examples.

Is There An AMPScript Editor?

One motive many corporations keep away from utilizing AMPScript is that, whereas highly effective, there are restricted sources to edit and take a look at AMPScript… so it may be fairly irritating. With no native editor within the platform that autocompletes and verifies your syntax for errors, Advertising and marketing Cloud customers are compelled to make use of third-party options or just write and take a look at, write and take a look at, write and take a look at. I’m not seeing a change to this any time quickly, so we’re going to offer some sources and examples right here which may be useful.

  • Ampscript.io – that is an internet AMPScript editor developed by Zuzanna Jarczynska. This software permits straightforward AMPscript modifying by way of syntax highlighting and it’ll warn you about attainable syntax errors in your code.
  • Microsoft Visible Studio – this Visible Studio Code extension means that you can join on to your Advertising and marketing Cloud Account, permits syntax highlighting for AMPScript, has built-in documentation for all AMPScript features, and in addition provides code snippets for language components and features. Every snippet features a detailed description of the perform and its parameters. Snippets additionally present up whenever you hover over a perform title.
  • Elegant Textual content with Bundle Management – this AMPScript syntax highlighter may be put in for the favored Elegant Textual content editor utilizing the set up package deal.

AMPScript Examples

Right here’s a easy instance of a customized message that’s constructed with AMPScript that pulls first and final title out of your Advertising and marketing Cloud subscriber attributes:

%%[

/* Set variables for personalized content */

SET @firstName = AttributeValue("FirstName")
SET @lastName = AttributeValue("LastName")

/* Insert personalized content into email message */

Hi @firstName,

Thank you for signing up for our newsletter! We hope you find the content valuable.

Sincerely,
The @lastName Family

]%%

Right here’s an instance the place we will dynamically change the content material of the message by trying up the curiosity attribute of a subscriber

%%[

/* Set variables for dynamic content */

SET @interest = AttributeValue("Interest")

/* Display content based on subscriber's interest */

IF @interest == "Sports" THEN
  Output(Concat("Check out our latest sports news and updates!"))
ELSEIF @interest == "Technology" THEN
  Output(Concat("Stay up-to-date on the latest tech trends and innovations with our newsletter!"))
ELSE
  Output(Concat("Discover a wide range of topics in our newsletter!"))
ENDIF

]%%

Or, in case you have a comma-separated attribute of pursuits, you possibly can see in case your time period is included within the attribute:

%%[

/* Set variables for personalized content */

SET @interestList = AttributeValue("InterestList")
SET @term = "Technology"

/* Check if term exists in interest list */

IF IndexOf(@interestList, @term) > 0 THEN
  Output(Concat("You are interested in technology!"))
ELSE
  Output(Concat("Your interests are not related to technology."))
ENDIF

]%%

You may even loop by way of an information extension to retrieve and show a particular variety of data.

%%[

/* Declare variables for personalized content */
var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i

/* Set variables for personalized content */
set @lookupValue = "Shirts"
set @numRowsToReturn = 3 /* 0 means all, max 2000 */

/* Query and retrieve the rows of data as well as their order */
set @rows = LookupOrderedRows("Orders",@numRowsToReturn,"OrderDate desc, ProductName asc", "ProductType", @lookupValue)
set @rowCount = rowcount(@rows)

/* Display each of the rows */
if @rowCount > 0 then

  for @i = 1 to @rowCount do

    var @ProductName, @OrderDate
    set @row = row(@rows,@i) /* get row based on counter */
    set @ProductName = field(@row,"ProductName")
    set @OrderDate = field(@row,"OrderDate")

    ]%%

    Row %%=v(@i)=%%, %%=v(@ProductName)=%% was ordered on %%=v(@OrderDate)=%%

    %%[ 
  next @i ]%%

%%[ else ]%%

No shirt orders discovered

%%[ endif ]%%

And, after all, you possibly can write HTML inside the output of your AMPScript to create lovely, dynamic HTML messages to your subscribers.

When you’re in search of help on improvement of your dynamic HTML e mail, dynamic SMS messages, or dynamic touchdown pages constructed on Cloud Pages, don’t hesitate to succeed in out to Highbridge for help.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments