Skip to main content

Ampscript 101: Amped About Ampscript

Savvy marketers know they can increase open, click, and conversion rates with personalized email marketing across multiple channels. Savvy marketers also know creating complex marketing communications can take a significant amount of effort, time and expertise. Consider these facts: 

  1. Personalized emails result in 29% higher unique open rates and 41% higher unique click rates.
  2. Higher open and click rates will increase conversion and revenue for your brand.
  3. Personalization is easy with Ampscript!

There are a multitude of personalization options available with Ampscript — from subject lines to hero images, to fully dynamic email content and custom cloud pages. This post will walk through everything you need to know about Ampscript — what it is, where it’s used in the Marketing Cloud platform, and some real-life examples of how marketers are using Ampscript to amp up their personalization. 

What is Ampscript?

Ampscript is a scripting language used in Salesforce Marketing Cloud emails, cloud pages and SMS messages to personalize content on a subscriber-by-subscriber basis. Even though Ampscript uses basic programming concepts, you don't have to be a coder to use it in your emails.  Ampscript interacts with data to pull dynamic information and is referenced via lookups. Ampscript can also insert or update data to data extensions as well.

Where is Ampscript used in the platform?

  • Subject Lines - FirstName, want to learn more about Ampscript?
  • Hero Images - Different images based on location, type of product they’re interested in, or other user preferences available in your data
  • Body Copy - Populate a product name, location, order numbers, or any other data point within the body copy
  • Custom URLs - Send a subscriber to the right landing page for them. Use Ampscript to append a product ID, order number or content page anchor to a base URL.
  • Cloud Pages - Build and manage a custom preference center in Marketing Cloud, build a form or survey, or customize product landing pages for users with Ampscript.
  • SMS Messages - Dynamically populate SMS messages with Ampscript to include first names, products, or other content similar to “body copy personalizations.”
  • Fully Dynamic Emails — Entire content selections are lookups from a data extension!

Customer Use Cases

Sending Personalized Content to Members
This national fitness chain, where members maximize the potential within themselves, has more than 100 clubs in the U.S., Canada, and the U.K. They wanted to leverage past click activity to identify the best content to send to their subscribers.

They used SQL to identify user preferences, based on past click behavior. (hint: _click data view + good alias assignments on links in their emails), and  to populate a data extension with the two best content blocks for each user. (hint: a data extension with the names of all available blocks and their associated alias’). They also populated email with custom blocks and log the block display so future sends don’t include the same block.

  • Used Ampscript “Lookup” function to identify which block and assign to a variable
    eg: set @Block1 = Lookup(‘BlockSections’, ‘Block1’, ‘SubscriberKey’, _SubscriberKey)
  • Used Ampscript “ContentBlockByKey” to display the assigned block
    eg: %%=ContentBlockByKey(@Block1)=%%
  • Used Ampscript to “Log” a value to a data extension so they can suppress it in future selections
    eg: %%[ InsertDE(‘BlockLogging’, ‘SubscriberKey’, _SubscriberKey, ‘Block1’, @Block1, ‘Block1Date’, NOW())

Personalized Recommendations for Readers 
This publishing company wanted to recommend other titles a customer might enjoy after downloading a specific eBook. 

They managed a detailed “Product” table with links, images, descriptions, and more for each ISBN (International Standard Book Number) and pre-populated a set of recommendations in the “Recommendations” table, by using Ampscript to pull the recommended ISBNs based on the originally downloaded ISBN.

  • eg: set @RecISBN1 = Lookup(‘Recommendations’, ‘Rec1’, ‘Orig_ISBN’, @Orig_ISBN)
    (Advanced version: check LookUpOrderedRows function and how to create an Ampscript Loop to set each recommendation programmatically.)

They also used additional Ampscript to pull in all the relevant product info for each recommended ISBN.

  • eg: set @ImageLink = Lookup(‘Products’, ‘ImageLink’, ‘ISBN’, @RecISBN1)
    (Advanced version: check out LookupRows function to lookup an entire product row, then assign the individual variables you need with Field functions. This method is more efficient at send time. Bonus, if you used a loop above you can place this code within the loop as well!)

For more help with Ampscript basics check out these resources from Salesforce: 

To learn more about Ampscript and for some more resources, check out Kaleigh’s entire session from Ultraviolet: Amped About Ampscript