ContentAreaByName
Inserts a Classic content area by its folder path and name. Runtime-proven on a live Marketing Cloud Engagement CloudPage — including the no-match default path and that default content is emitted literally. Classic content is retired; prefer ContentBlockByName.
Syntax
ContentAreaByName(contentAreaName[, impressionRegionName, errorOnMissingContentArea, errorMessage, statusCode]) → string
ContentAreaByName references Classic content areas, which are no longer supported. Author new content in Content Builder and retrieve it with ContentBlockByName.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
contentAreaName |
string | Yes | Folder path and name 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 = ContentAreaByName("nosuch\Folder\Area", "", 0, "Area unavailable", @sc)
]%%
%%=v(@out)=%%
Renders Area unavailable and sets @sc to -1 — the clean no-match path when the name does not resolve.
When the name does resolve, the bare form inserts the stored content area:
%%=ContentAreaByName('My Folder\My Content')=%%
Return value
string — the rendered HTML of the named 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 name with the error flag set to 0 returns the default content. An unresolved folder-path name with errorOnMissingContentArea 0 renders the default content and sets the status variable to -1 instead of aborting the page.
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 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 = ContentAreaByName("nosuch\Folder\Area", "", 0, "FB-CAN", @sc)
OutputLine(Concat("miss=[", @miss, "] sc=[", @sc, "]"))
/* default content is emitted literally - the inline AMPscript is NOT evaluated */
SET @lit = ContentAreaByName("nosuch\Folder\Area", "", 0, "PRE-%%=Add(2,3)=%%-POST", @sc)
OutputLine(Concat("lit=[", @lit, "]"))
ENDIF
]%%
OutputLine given a bare string literal renders an empty line. Wrap the argument in Concat() or your start and done markers vanish silently — which looks exactly like the function failing.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes (Classic content, deprecated) |
| Marketing Cloud Next | No |
See also
ContentArea— the same Classic lookup keyed by numeric IDContentBlockByKey— the Content Builder replacement keyed by customer key- Official reference · ampscript.guide