AMPscript Domain (Next)
Return everything after the first at sign of an email address with AMPscript Domain in Marketing Cloud Next. Syntax, examples, and behaviour proven in a Marketing Cloud Next email.
Syntax
Domain(emailAddress) → string
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
emailAddress |
string | Yes | Email address; the text after the first at sign is returned verbatim |
Example
%%=Domain("tomas.q@example.com")=%%
Renders example.com.
The casing of the address is kept, so fold it before comparing against a list of domains:
%%=Lowercase(Domain("Tomas.Q@Example.COM"))=%%
Renders example.com.
Return value
string — the text after the first at sign, unchanged.
The result is open text. Inputs without a usable domain part render nothing at all, so test the result for emptiness rather than comparing it with a literal.
Behaviour
The split happens at the first at sign. Domain("a@b@example.com") gives b@example.com: the second at sign stays in the result.
Multi-level domains come back whole. Domain("tomas.q@a.b.example.co.uk") gives a.b.example.co.uk, and the six-label Domain("tomas.q@sub.a.b.example.co.uk") also keeps every label (sub.a.b.example.co.uk).
Casing is preserved. Domain("Tomas.Q@Example.COM") gives Example.COM.
The address is not validated. Domain("tomas q@example.com") gives example.com despite the space, and Domain("hello@world") gives world.
A plus tag makes no difference. Domain("tomas.q+news@example.com") gives example.com.
What comes back for each shape
| Call | Renders |
|---|---|
Domain("tomas.q@example.com") |
example.com |
Domain("tomas.q+news@example.com") |
example.com |
Domain("tomas.q@a.b.example.co.uk") |
a.b.example.co.uk |
Domain("a@b@example.com") |
b@example.com |
Domain("Tomas.Q@Example.COM") |
Example.COM |
Domain("hello@world") |
world |
Domain("example.com") |
(empty) |
Domain("tomas.q@") |
(empty) |
Domain("@") |
(empty) |
Domain("") |
(empty) |
Domain(123) |
(empty) |
A call with the wrong number of arguments was not tried in Next.
Show Next test script
<!-- Marketing Cloud Next test script for Domain. Paste it into the HTML component of a
Next email and open the preview. Each line prints the result Next gave when the call
was rendered on its own (expect) next to the result of this run (got).
Assembled from single-call test emails (dates on the page); it has not been
run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[example.com] got=[%%=Domain("user@example.com")=%%]</p>
<p>c2 expect=[a.b.example.co.uk] got=[%%=Domain("tomas.q@a.b.example.co.uk")=%%]</p>
<p>c3 expect=[Example.COM] got=[%%=Domain("Tomas.Q@Example.COM")=%%]</p>
<p>c4 expect=[b@example.com] got=[%%=Domain("a@b@example.com")=%%]</p>
<p>c5 expect=[sub.a.b.example.co.uk] got=[%%=Domain("tomas.q@sub.a.b.example.co.uk")=%%]</p>
<p>c6 expect=[] got=[%%=Domain("example.com")=%%]</p>
<p>c7 expect=[] got=[%%=Domain("")=%%]</p>
<p>c8 expect=[world] got=[%%=Domain("hello@world")=%%]</p>
<p>c9 expect=[example.com] got=[%%=Domain("tomas.q+news@example.com")=%%]</p>
<p>c10 expect=[example.com] got=[%%=Domain("tomas q@example.com")=%%]</p>
<p>c11 expect=[] got=[%%=Domain("tomas.q@")=%%]</p>
<p>c12 expect=[] got=[%%=Domain("@")=%%]</p>
<p>c13 expect=[] got=[%%=Domain(123)=%%]</p>
Differs from official docs
- It works in Next although the docs say it does not. The official availability table marks
Domainas unsupported in Marketing Cloud Next. In a Next email it saved and rendered, for exampleexample.comfor a plain address. Card
Availability & differences
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | Yes, from API 68.0 |
Every address shape tried renders the same in Engagement, from example.com for a plain address to an empty result for a string without an at sign. Compared 2026-11-23 by rendering the same calls in a Marketing Cloud Next email.
See also
- IsEmailAddress — validate the address before splitting it
- Empty — test a variable holding the result for emptiness
- Lowercase — fold the case before comparing
- Official reference