CloudPagesURL
→ stringBuilds an encrypted URL for a CloudPages landing page with optional name/value parameters. Parameters are encrypted so they cannot be tampered with.
Available in:
Email
CloudPage
Automation
Triggered Send
Syntax
Platform.Function.CloudPagesURL(pageId [, param1, value1, param2, value2, ...])
1+ arguments
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pageId |
number | Yes | The page ID of the CloudPages landing page |
param1 |
string | No | First parameter name |
value1 |
string | No | First parameter value |
param2 |
string | No | Second parameter name |
value2 |
string | No | Second parameter value |
Description
CloudPagesURL generates a URL for a CloudPages landing page. Parameters are encrypted by SFMC — they cannot be read or tampered with by the subscriber. The page reads them via Platform.Request.GetQueryStringParameter().
This is the recommended way to pass sensitive data (like subscriber keys) in email links to CloudPages.
Examples
Basic CloudPages link
var pageId = 12345;
var url = Platform.Function.CloudPagesURL(pageId);
Write('<a href="' + url + '">Visit your preferences</a>');
With parameters
var url = Platform.Function.CloudPagesURL(
12345,
"sk", subscriberKey,
"email", emailAddress
);
Write('<a href="' + url + '">Update preferences</a>');
In an email context
var preferencesUrl = Platform.Function.CloudPagesURL(
99001,
"sk", _subscriberKey,
"ref", "email_footer"
);
Variable.SetValue("@preferencesUrl", preferencesUrl);
Then in AMPscript/HTML:
<a href="%%=v(@preferencesUrl)=%%">Manage Email Preferences</a>
Reading the parameters on the CloudPage
// On the CloudPage receiving the encrypted link:
var sk = Platform.Request.GetQueryStringParameter("sk");
var email = Platform.Request.GetQueryStringParameter("email");
Notes
- Parameters passed to
CloudPagesURLare encrypted — subscribers cannot see or modify them - The encryption key is tied to the SFMC account — links from one account won’t decrypt in another
- Parameters are accessible via
Platform.Request.GetQueryStringParameter()on the target page - For non-encrypted parameters, just append them as a regular query string