MicrositeURL
Builds a Classic Content microsite URL. Runtime-proven on a live Marketing Cloud Engagement CloudPage — the page reference and any extra name-value pairs are folded into one encrypted token, and every call produces a different token.
Syntax
MicrositeURL(pageId[, paramName1, paramValue1, paramNameN, paramValueN, ...]) → string
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pageId |
string | number | Yes | Microsite page ID |
paramName1 |
string | No | Query parameter name |
paramValue1 |
string | No | Query parameter value |
paramNameN |
string | No | Additional query parameter name |
paramValueN |
string | No | Additional query parameter value |
Name and value are supplied as a pair, and the pairs repeat for as long as you need them.
Example
%%[
VAR @link
SET @link = MicrositeURL(1467160, "offer", "spring")
]%%
<a href="%%=v(@link)=%%">Open the page</a>
The rendered href is a microsite host followed by a single query parameter carrying one long opaque token. Neither offer nor spring appears anywhere in it — the pair is inside the token. Render the same block twice and the two tokens differ, so never compare the result against a stored copy.
Return value
string — a microsite page URL carrying exactly one encrypted token.
The value domain is open, so there is no set of sentinel values to test for. What is fixed is the shape: one host, one path, one query parameter, one token. Everything you passed — the page reference and every extra pair — lives inside that token.
Behaviour
Extra name-value pairs are encrypted, not appended. Adding a single pair lengthened the result by thirteen characters against the same call without it, while neither the name nor the value could be found anywhere in the string. There is still exactly one query parameter afterwards. Do not expect to read your own parameters back out of the URL.
Every call returns a different URL. Two calls with identical arguments in one render produced two different tokens of the same length. The result must never be compared, deduplicated or cached as an identity.
An ID that does not exist is accepted. A nine-digit ID matching no asset produced a well-formed URL of the same shape. The function builds the link without checking that the referenced page exists, so a typo in the ID fails only when someone opens the link.
The ID may be a number or a quoted string. Both spellings of the same ID, and the ID passed through a variable, all produced valid URLs. Our own catalog previously typed it as a number only.
Exactly one required argument. A zero-argument call aborts the request with HTTP 422, as does a call supplying a name without its value. The maximum is open, as the pairs repeat.
The same calls were re-run on a parent business unit and behaved identically, so none of the above is an artefact of a child account.
Show test script
%%[
VAR @b, @u1, @u2, @m1
SET @b = RequestParameter("b")
/* known-good control: renders on every request, so a run of HTTP 422s
can be told apart from a broken deploy */
OutputLine(Concat("CTRL=[", Uppercase("ok"), "]"))
OutputLine(Concat("GATE=[", @b, "]"))
/* a real page ID, called twice, then the same ID as a quoted string:
the two tokens differ although the lengths match */
IF @b == "msulit" THEN
OutputLine(Concat("--- msulit start ---"))
SET @u1 = MicrositeURL(1467160)
SET @u2 = MicrositeURL(1467160)
OutputLine(Concat("MSU_LIT=[", @u1, "] LEN=[", Length(@u1), "]"))
OutputLine(Concat("MSU_LIT_SAME=[", IIf(@u1 == @u2, "identical", "different"), "]"))
SET @m1 = MicrositeURL("1467160")
OutputLine(Concat("MSU_STRLIT=[", @m1, "] LEN=[", Length(@m1), "]"))
OutputLine(Concat("--- msulit done ---"))
ENDIF
/* one extra pair: the length grows but neither the name nor the value
is readable in the result */
IF @b == "msuparams" THEN
OutputLine(Concat("--- msuparams start ---"))
SET @u1 = MicrositeURL(1467160, "alpha", "one")
OutputLine(Concat("MSU_P1=[", @u1, "] LEN=[", Length(@u1), "]"))
OutputLine(Concat("MSU_P1_HASALPHA=[", IndexOf(@u1, "alpha"), "]"))
OutputLine(Concat("--- msuparams done ---"))
ENDIF
/* an ID that matches no asset: still a well-formed URL */
IF @b == "msubad" THEN
OutputLine(Concat("--- msubad start ---"))
SET @u1 = MicrositeURL(987654321)
OutputLine(Concat("MSU_BAD=[", @u1, "] LEN=[", Length(@u1), "]"))
OutputLine(Concat("--- msubad done ---"))
ENDIF
/* argument counts the signature does not allow: each aborts its own
branch with HTTP 422 while every branch above still renders */
IF @b == "msu0" THEN
OutputLine(Concat("MSU0_START=[x]"))
OutputLine(Concat("MSU0=[", MicrositeURL(), "]"))
ENDIF
IF @b == "msu2" THEN
OutputLine(Concat("MSU2_START=[x]"))
OutputLine(Concat("MSU2=[", MicrositeURL(1467160, "alpha"), "]"))
ENDIF
]%%
One thing the harness cannot reach: what the token resolves to on the target page. That needs a real send with a real subscriber, so the personalisation the official reference describes is untested here — only the token’s existence, its per-call variation and its absorption of extra pairs were proven.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | No |
See also
CloudPagesURL— the CloudPages counterpart. It has no page here yet: no invocation of it could be made to render from a CloudPage, so nothing about it is runtime-proven- v — outputs the built URL inline
- Official reference · ampscript.guide