Returns the number of characters in a string.
Availability
<table> <tr> <td>Marketing Cloud Engagement</td> <td>✅ Yes</td> </tr> <tr> <td>Marketing Cloud Next</td> <td>✅ Yes</td> </tr> </table>This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).
Syntax
Length(sourceString)
The Length function has one parameter:
sourceString(string): Required. The string that you want to find the length of.
Usage
To use this function, pass it a string. This example uses the Length() function to determine if the length of a URL exceeds a certain threshold. If it does, then the function passes the URL to the WrapLongUrl() function to obtain a shortened URL. Otherwise, the function uses the original URL.
%%[
Var @imageUrl, @imageUrlLength
/* A very long string that contains 1200 characters */
Set @imageUrl = "https://cdn.example.com/images/0800fc577294c34...e0b28ad2839435945/28ad2839435945.png"
Set @imageUrlLength = Length(@imageUrl)
If @imageUrlLength >= 975 then
]%%
<img src="%%=WrapLongUrl(@imageUrl)=%%" />
%%[ Else ]%%
<img src="%%=v(@imageUrl)=%%" />
%%[ EndIf ]%%
The example outputs an image with a src URL that varies based on the length of the source URL.