Runtime verified Test scripts included

Syntax

ContentArea(contentAreaId[, impressionRegionName, errorOnMissingContentArea, errorMessage, statusCode])  →  string
1–5 arguments

Parameters

Name Type Required Description
contentAreaId number | string Yes ID of the Classic content area to retrieve
impressionRegionName string No Impression region name to associate with the content area
errorOnMissingContentArea boolean No When true (the default), a missing area aborts; set to 0 to fall back to the default content
errorMessage string No Default content returned when the area is missing — emitted literally
statusCode number No Output variable set to 0 on success or -1 when no content was found

Example

%%[
  VAR @sc, @out
  SET @out = ContentArea(999999999, "", 0, "Area unavailable", @sc)
]%%
%%=v(@out)=%%

Renders Area unavailable and sets @sc to -1 — the clean no-match path when the ID does not resolve.

When the ID does resolve, the bare form inserts the stored content area:

%%=ContentArea(12345)=%%

Return value

string — the rendered HTML of the referenced content area, or the errorMessage default when the area is missing and errorOnMissingContentArea is 0. There is no closed set of sentinel values.

Behaviour

A missing ID with the error flag set to 0 returns the default content. ContentArea(999999999, "", 0, "FB", @sc) renders FB and sets the status variable to -1 instead of aborting the page — this is the load-bearing path for Classic content, which is no longer present on modern accounts.

The default content is emitted literally. A default containing an inline expression renders verbatim; the embedded AMPscript is not evaluated. Use TreatAsContent if the fallback string itself needs to run.

The function is still callable at runtime. Even though Classic content is retired, the call itself resolves and follows the documented default-content path rather than raising an unknown-function error.

Show test script
%%[
  VAR @b, @sc, @miss, @lit
  SET @b = RequestParameter("b")

  /* safe sweep: the missing/default paths are accepted and share one request */
  IF @b == "safe" THEN
    /* missing with error flag 0: returns the default content and sets status to -1 */
    SET @miss = ContentArea(999999999, "", 0, "FB-CA", @sc)
    OutputLine(Concat("miss=[", @miss, "] sc=[", @sc, "]"))

    /* default content is emitted literally - the inline AMPscript is NOT evaluated */
    SET @lit = ContentArea(999999999, "", 0, "PRE-%%=Add(2,3)=%%-POST", @sc)
    OutputLine(Concat("lit=[", @lit, "]"))
  ENDIF
]%%

Availability

Platform Available
Marketing Cloud Engagement Yes (Classic content, deprecated)
Marketing Cloud Next No

See also