AMPscript AuthenticatedEmployeeID
Returns the numeric employee ID of the Marketing Cloud user tied to the current context. A public, anonymous request still gets a non-empty ID back, so a non-empty result proves nothing about who is visiting.
Syntax
AuthenticatedEmployeeID() → string
Parameters
This function takes no parameters.
Example
%%[
VAR @employeeId
SET @employeeId = AuthenticatedEmployeeID()
]%%
User: %%=v(@employeeId)=%%
Renders a nine-digit numeric ID — the same value on every request, including anonymous ones.
The value is an ordinary string, so it composes normally:
%%[
VAR @employeeId, @label
SET @employeeId = AuthenticatedEmployeeID()
SET @label = Concat("employee-", @employeeId)
]%%
%%=v(@label)=%%
What it does not support is a sign-in check — see below.
Return value
string — a numeric employee ID.
The value domain is open: an ID is an account-scoped number, so there is no closed set of sentinel values to test for. In particular there is no “not signed in” sentinel — an unauthenticated request gets an ordinary ID back.
Behaviour
A public CloudPage request gets a value, not an empty result. An anonymous request to the published URL, carrying no Marketing Cloud session at all, rendered a nine-digit ID at HTTP 200. Empty() on the same value answered false and Length() gave nine.
The result is a value, not a page-terminating call. It compared against the empty string, rendered inline without a variable, and rendered unchanged nested inside a Concat between two surrounding characters. Every line after the call still rendered.
The value is stable inside one render. Three separate calls in the same request — an assignment, an inline call and a nested call — produced identical digits.
Do not use it as an authentication check
Because a value always comes back, a page cannot infer from a non-empty result that its visitor is a signed-in Marketing Cloud user. Content gated on that check would be open to everyone. Use a real authentication mechanism for the gate and treat this function as context information only.
Show test script
%%[
VAR @b, @aeid
SET @b = RequestParameter("b")
/* known-good control: renders on every request, so a run of HTTP 422s
can be told apart from a deploy that failed to compile */
OutputLine(Concat("CTRL=[", Uppercase("ok"), "]"))
OutputLine(Concat("--- AEID start ---"))
/* a plain anonymous request still produces a value */
SET @aeid = AuthenticatedEmployeeID()
OutputLine(Concat("AEID=[", @aeid, "]"))
/* confirmed with a second function rather than read off empty brackets */
OutputLine(Concat("AEID_EMPTY=[", IIf(Empty(@aeid), "empty", "not-empty"), "]"))
OutputLine(Concat("AEID_LEN=[", Length(Concat(@aeid, "")), "]"))
/* the value is usable inline, nested and in a comparison */
OutputLine(Concat("AEID_DIRECT=[", AuthenticatedEmployeeID(), "]"))
OutputLine(Concat("AEID_IN_CONCAT=[", Concat("<", AuthenticatedEmployeeID(), ">"), "]"))
OutputLine(Concat("AEID_CMP=[", IIf(@aeid == "", "eq-emptystring", "ne-emptystring"), "]"))
OutputLine(Concat("--- AEID done ---"))
/* argument counts the signature does not allow: each aborts its branch */
IF @b == "ar1" THEN
OutputLine(Concat("--- ar1 start ---"))
OutputLine(Concat("AEID1=[", AuthenticatedEmployeeID("x"), "]"))
OutputLine(Concat("--- ar1 done ---"))
ENDIF
IF @b == "ar2" THEN
OutputLine(Concat("--- ar2 start ---"))
OutputLine(Concat("AEID2=[", AuthenticatedEmployeeID("x", "y"), "]"))
OutputLine(Concat("--- ar2 done ---"))
ENDIF
]%%
Every marker and label in the test script goes through Concat(...), including single-argument ones. A bare string literal passed to OutputLine renders an empty line while the page still returns HTTP 200, so the marker silently vanishes.
Context and requirements
The official reference scopes this function to microsites using sender authenticated redirection and states it is not for CloudPages. That authenticated path needs a session a public CloudPage cannot supply, so this page describes the unauthenticated CloudPage context only, and makes no claim about whose identity the returned ID represents.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | No |