Encodes non-URL components of a string.
This function encodes only characters that follow a URL, such as a query string. To encode an entire string, use encodeURI.
Availability
This helper is available in the Winter ’27 release of Marketing Cloud Next.
Syntax
{{encodeURIComponent stringToEncode}}
Parameters
| Parameter | Type | Description |
|---|---|---|
stringToEncode |
String | Required. The string to encode. |
Return Value
The function returns the URL-encoded string.
Usage Example
This example encodes a string of text so that it's safe to include in a URL, converting all spaces and special characters.
{{encodeURIComponent
"https://www.example.com/app?firstName=Cruz&lastName=De La Rosa&email=cdelarosa@example.com"
}}
The function returns this URL-encoded string:
https://www.example.com/app?firstName=Cruz&lastName=De+La+Rosa&email=cdelarosa%40example.com