Runtime verified

Syntax

AuthenticatedMemberID()  →  string
0 arguments — exactly

Parameters

This function takes no parameters.

Example

%%[
  VAR @memberId
  SET @memberId = AuthenticatedMemberID()
]%%
Business unit: %%=v(@memberId)=%%

Renders a short run of digits with no punctuation — on the business unit tested, nine digits.

Because the digits behave as a real number, the value can be matched against a MID you already know without any string juggling, which is the usual way to branch content per business unit:

%%[
  VAR @memberId, @isProductionBu
  SET @memberId = AuthenticatedMemberID()
  SET @isProductionBu = IIf(@memberId == "123456789", "yes", "no")
]%%
%%=v(@isProductionBu)=%%

The MID it hands back is the running business unit’s, not the account’s — see below.

Return value

string — a business unit member ID.

The value domain is open: a MID varies per business unit, 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 MID 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 MID at HTTP 200. Empty() on the same value answered false and Length() gave 9.

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 like AuthenticatedEnterpriseID and 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 business unit’s MID, not the account’s

The page under test was published on a child business unit. The returned value matched that child’s own MID exactly, and did not match the account’s parent (enterprise) 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.

The pairing is what makes it useful: AuthenticatedEnterpriseID, called in the same render, came back as the parent MID — a different, shorter digit string. So the two functions answer two different questions. Reach for this one when you want the business unit executing the code, and for the enterprise one when you want the account.

It is also not the employee identifier. AuthenticatedEmployeeID in the same render returned a digit string of the same length — nine — yet a direct comparison answered different, and IndexOf answered 0, its not-found result, in both directions. Equal length is not equal value; do not treat one as a stand-in for 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, @mid, @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("--- AMID start ---"))

  /* a plain anonymous request still produces a value */
  SET @mid = AuthenticatedMemberID()
  OutputLine(Concat("AMID=[", @mid, "]"))

  /* confirmed with a second function rather than read off empty brackets */
  OutputLine(Concat("AMID_EMPTY=[", IIf(Empty(@mid), "empty", "not-empty"), "]"))
  OutputLine(Concat("AMID_LEN=[", Length(Concat(@mid, "")), "]"))

  /* the value is usable inline, nested and in a comparison */
  OutputLine(Concat("AMID_DIRECT=[", AuthenticatedMemberID(), "]"))
  OutputLine(Concat("AMID_IN_CONCAT=[", Concat("<", AuthenticatedMemberID(), ">"), "]"))
  OutputLine(Concat("AMID_CMP=[", IIf(@mid == "", "eq-emptystring", "ne-emptystring"), "]"))
  OutputLine(Concat("--- AMID done ---"))

  /* what the value looks like, which MID it is, and how it relates to its siblings */
  IF @b == "shape" THEN
    OutputLine(Concat("--- shape start ---"))
    OutputLine(Concat("DOT_POS=[", IndexOf(@mid, "."), "]"))
    OutputLine(Concat("SPACE_POS=[", IndexOf(@mid, " "), "]"))
    OutputLine(Concat("AT_POS=[", IndexOf(@mid, "@"), "]"))
    OutputLine(Concat("DASH_POS=[", IndexOf(@mid, "-"), "]"))
    OutputLine(Concat("PARENT_MID_MATCH=[", IIf(@mid == "0000000", "yes", "no"), "]"))
    OutputLine(Concat("CHILD_MID_MATCH=[", IIf(@mid == "000000000", "yes", "no"), "]"))
    SET @eid = AuthenticatedEnterpriseID()
    SET @empid = AuthenticatedEmployeeID()
    OutputLine(Concat("EID_LEN=[", Length(Concat(@eid, "")), "]"))
    OutputLine(Concat("SAME_AS_EID=[", IIf(@mid == @eid, "identical", "different"), "]"))
    OutputLine(Concat("EMPID_LEN=[", Length(Concat(@empid, "")), "]"))
    OutputLine(Concat("SAME_AS_EMPID=[", IIf(@mid == @empid, "identical", "different"), "]"))
    OutputLine(Concat("AMID_IN_EMPID=[", IndexOf(@empid, @mid), "]"))
    OutputLine(Concat("EMPID_IN_AMID=[", IndexOf(@mid, @empid), "]"))
    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(@mid, 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("AMID1=[", AuthenticatedMemberID("x"), "]"))
    OutputLine(Concat("--- ar1 done ---"))
  ENDIF

  IF @b == "ar2" THEN
    OutputLine(Concat("--- ar2 start ---"))
    OutputLine(Concat("AMID2=[", AuthenticatedMemberID("x", "y"), "]"))
    OutputLine(Concat("--- ar2 done ---"))
  ENDIF
]%%

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 session the returned MID would reflect on a microsite.

See also