AuthenticatedEnterpriseID
Returns the enterprise ID (EID) of the Marketing Cloud account tied to the current context. Runtime-proven on a live Marketing Cloud Engagement CloudPage — a public, anonymous request gets the account's parent MID back even when the page itself runs on a child business unit.
Syntax
AuthenticatedEnterpriseID() → string
Parameters
This function takes no parameters.
Example
%%[
VAR @enterpriseId
SET @enterpriseId = AuthenticatedEnterpriseID()
]%%
Account: %%=v(@enterpriseId)=%%
Renders a short run of digits with no punctuation — on the account tested, seven digits.
Because the digits behave as a real number, the value can be matched against a MID you already know without any string juggling:
%%[
VAR @enterpriseId, @isExpectedAccount
SET @enterpriseId = AuthenticatedEnterpriseID()
SET @isExpectedAccount = IIf(@enterpriseId == "1234567", "yes", "no")
]%%
%%=v(@isExpectedAccount)=%%
The MID it hands back is the account’s, not the running business unit’s — see below.
Return value
string — an enterprise ID.
The value domain is open: an account ID is account-scoped and varies per Marketing Cloud account, 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 an ID at HTTP 200. Empty() on the same value answered false and Length() gave 7.
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 output.
It is digits, and they are numeric. IndexOf found no dot, no space, no @ and no dash anywhere in the value, so unlike the email-shaped Authenticated* siblings it carries no punctuation at all. Add() applied straight to the value returned it incremented by one, so it is a numeric string rather than opaque text.
It is the account MID, not the business unit’s
The page under test was published on a child business unit. The returned value nevertheless matched the account’s parent (enterprise) MID exactly, and did not match the child business unit’s own MID. Both comparisons ran in the same render against the two real MIDs configured for the account, so the answer is not an artefact of a made-up identifier.
Read the result as an account-level identifier. If what you actually need is the MID of the business unit executing the code, this is not that function.
It is also not the employee identifier: called in the same render, AuthenticatedEmployeeID came back a different, longer digit string, and IndexOf answered 0 — its not-found result — in both directions, so neither value is a substring of the other.
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, @eid, @empid
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 @eid = AuthenticatedEnterpriseID()
OutputLine(Concat("AEID=[", @eid, "]"))
/* confirmed with a second function rather than read off empty brackets */
OutputLine(Concat("AEID_EMPTY=[", IIf(Empty(@eid), "empty", "not-empty"), "]"))
OutputLine(Concat("AEID_LEN=[", Length(Concat(@eid, "")), "]"))
/* the value is usable inline, nested and in a comparison */
OutputLine(Concat("AEID_DIRECT=[", AuthenticatedEnterpriseID(), "]"))
OutputLine(Concat("AEID_IN_CONCAT=[", Concat("<", AuthenticatedEnterpriseID(), ">"), "]"))
OutputLine(Concat("AEID_CMP=[", IIf(@eid == "", "eq-emptystring", "ne-emptystring"), "]"))
OutputLine(Concat("--- AEID done ---"))
/* what the value looks like, which MID it is, and whether it is the sibling id */
IF @b == "shape" THEN
OutputLine(Concat("--- shape start ---"))
OutputLine(Concat("DOT_POS=[", IndexOf(@eid, "."), "]"))
OutputLine(Concat("SPACE_POS=[", IndexOf(@eid, " "), "]"))
OutputLine(Concat("AT_POS=[", IndexOf(@eid, "@"), "]"))
OutputLine(Concat("DASH_POS=[", IndexOf(@eid, "-"), "]"))
SET @empid = AuthenticatedEmployeeID()
OutputLine(Concat("EMPID_LEN=[", Length(Concat(@empid, "")), "]"))
OutputLine(Concat("SAME_AS_EMPID=[", IIf(@eid == @empid, "identical", "different"), "]"))
OutputLine(Concat("AEID_IN_EMPID=[", IndexOf(@empid, @eid), "]"))
OutputLine(Concat("EMPID_IN_AEID=[", IndexOf(@eid, @empid), "]"))
OutputLine(Concat("PARENT_MID_MATCH=[", IIf(@eid == "0000000", "yes", "no"), "]"))
OutputLine(Concat("CHILD_MID_MATCH=[", IIf(@eid == "000000000", "yes", "no"), "]"))
OutputLine(Concat("--- shape done ---"))
ENDIF
/* the digits behave as a number, not only as text */
IF @b == "num" THEN
OutputLine(Concat("--- num start ---"))
OutputLine(Concat("PLUS1=[", Add(@eid, 1), "]"))
OutputLine(Concat("--- num done ---"))
ENDIF
/* argument counts the signature does not allow: each aborts its branch */
IF @b == "ar1" THEN
OutputLine(Concat("--- ar1 start ---"))
OutputLine(Concat("AEID1=[", AuthenticatedEnterpriseID("x"), "]"))
OutputLine(Concat("--- ar1 done ---"))
ENDIF
IF @b == "ar2" THEN
OutputLine(Concat("--- ar2 start ---"))
OutputLine(Concat("AEID2=[", AuthenticatedEnterpriseID("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.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | No |
The official reference scopes this function to microsites using sender authenticated redirection and states it is not for CloudPages. That authenticated path was not exercised here — a public CloudPage cannot supply such a session — so everything on this page describes the unauthenticated CloudPage context only, and no claim is made about whose account the returned ID represents.