top of page
Writer's pictureLeila

4 SFMC.Essentials AmpScript functions to know

Updated: Mar 18, 2023

AmpScript should enable even those without programming and development experience to handle straightforward use cases.



#1 WrapLongURL

This function shortens URLs longer than 975 characters to mitigate broken email hyperlinks in Microsoft Outlook, where lengths of URL hyperlinks are restricted to the following number of characters:

  • Outlook 2007: 975 characters

  • Outlook 2007: 1033 characters

  • Outlook 2007: 2048 characters


Example

%%[

var @icon
set @icon = "https://limedash.com/images/rRprc5xG8vP0crpSqWLScVu6yKLTm...lKJK91napRdf6b+DAy/ixM.jpg" /* abbreviated for display purposes */

]%%
<img src="%%=WrapLongURL(@icon)=%%" width="50" height="50" alt="icon" />

Output

The value of the src attribute will be shortened to a URL which redirects to the original URL.

http://cl.exct.net/ResolveURL.aspxqs=faebf571997acc80ec99646da21ae0ab

#2 Propercase

This AmpScript function capitalizes the first letter in the specified string and any other letters in the string that follow any character other than a letter. It converts all other letters into lowercase.


Example:

%%[

var @fullName, @fullNameProperCase

set @fullName = AttributeValue("fullName") /* value from attribute or DE column in send context */
set @fullName = "SFMC ESSENTIALS" /* or a literal value */

set @fullNameProperCase = ProperCase(@fullName)

]%%
fullName: %%=v(@fullName)=%%
<br>fullNameProperCase: %%=v(@fullNameProperCase)=%%

Output

fullName: SFMC ESSENTIALS
fullNameProperCase: Sfmc Essentials



#3 Random

Finding yourself needing to display a random number? We see you, creative marketer! This function returns a random number between two numbers. Both upper and lower bound parameters are inclusive.



Example

%%[

var @random, @num1, @num2

set @num1 = 1
set @num2 = 100

set @random  = random(@num1, @num2)

]%%
Lower bound: %%=v(@num1)=%%
<br>Upper bound: %%=v(@num2)=%%
<br>Random: %%=v(@random)=%%

Output

Lower bound: 1
Upper bound: 100
Random: 42


#4 Concat

This function concatenates one or more strings.


Example

%%[

var @firstName
var @lastName
var @fullName

set @firstName = AttributeValue("firstName") /* value from attribute or DE column in send context */
set @firstName = "Suzy" /* or a literal value */

set @lastName = AttributeValue("lastName") /* value from attribute or DE column in send context */
set @lastName = "Jackson" /* or a literal value */

set @fullName  = Concat(@firstName, " ", @lastName)

]%%
firstName: %%=v(@firstName)=%%
<br>lastName: %%=v(@lastName)=%%
<br>fullName: %%=v(@fullName)=%%

Output

firstName: Suzy
lastName: Jackson
fullName: Suzy Jackson



You now have the SFMC.Essentials guidance to be awesome, happy fixing! Need an extra pair of hands to troubleshoot?

SFMC.Essential events to inspire and share SFMC knowledge, want to join?


47 views0 comments

Comments


Commenting has been turned off.
bottom of page