AMPscript GUID (Next)
Generate a new globally unique identifier with AMPscript GUID in Marketing Cloud Next. Syntax, examples, and behaviour proven in a Marketing Cloud Next email, including the format of the value.
Syntax
GUID() → string
Parameters
This function takes no parameters. An email that calls GUID("x") cannot be saved in Next: the content API answers HTTP 400 with “The AMPscript syntax isn’t valid”.
Example
%%[ SET @token = GUID() ]%%
%%=v(@token)=%%
Renders a value such as b3699a44-8716-4950-a23a-026a10263c12.
Keep the value in a variable when you need it twice, because every call returns a new one.
Return value
string — a 36-character identifier.
| Property | Value |
|---|---|
| Length | 36 characters |
| Groups | 8, 4, 4, 4, 12 |
| Hyphen positions | 9, 14, 19, 24 |
| Character at position 15 | 4 |
| Braces | none |
Behaviour
The shape is fixed. Length(GUID()) gives 36. Cutting a value into its groups gives lengths 8-4-4-4-12, the characters at positions 9, 14, 19 and 24 are all hyphens, and position 15 holds 4.
There are no braces. IndexOf finds neither { nor } (both 0), while the first hyphen is found at 9.
Each call gives a new value. Two calls stored in two variables compare as different.
A sample value printed in lowercase hex. Do not test the case with ==: in Next == compares strings without regard to case, so @g == Uppercase(@g) is true, where Engagement gives false. See IIf.
Show Next test script
<!-- Marketing Cloud Next test script for GUID. 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=[b3699a44-8716-4950-a23a-026a10263c12] got=[%%=GUID()=%%]</p>
<p>c2 expect=[36] got=[%%=Length(GUID())=%%]</p>
<p>c3 expect=[----] got=[%%[ SET @r2g1 = GUID() ]%%%%=Concat(Substring(@r2g1,9,1),Substring(@r2g1,14,1),Substring(@r2g1,19,1),Substring(@r2g1,24,1))=%%]</p>
<p>c4 expect=[8-4-4-4-12] got=[%%[ SET @r2g2 = GUID() ]%%%%=Concat(Length(Substring(@r2g2,1,8)),"-",Length(Substring(@r2g2,10,4)),"-",Length(Substring(@r2g2,15,4)),"-",Length(Substring(@r2g2,20,4)),"-",Length(Substring(@r2g2,25,12)))=%%]</p>
<p>c5 expect=[eq-lower] got=[%%[ SET @r2g3 = GUID() IF @r2g3 == Lowercase(@r2g3) THEN SET @r2g3r = "eq-lower" ELSE SET @r2g3r = "ne-lower" ENDIF ]%%%%=v(@r2g3r)=%%]</p>
<p>c6 expect=[0|0|9] got=[%%[ SET @r2g5 = GUID() ]%%%%=Concat(IndexOf(@r2g5,"{"),"|",IndexOf(@r2g5,"}"),"|",IndexOf(@r2g5,"-"))=%%]</p>
<p>c7 expect=[different] got=[%%[ SET @r2g6a = GUID() SET @r2g6b = GUID() IF @r2g6a == @r2g6b THEN SET @r2g6r = "same" ELSE SET @r2g6r = "different" ENDIF ]%%%%=v(@r2g6r)=%%]</p>
<p>c8 expect=[4] got=[%%[ SET @r2g7 = GUID() ]%%%%=Substring(@r2g7,15,1)=%%]</p>
Show calls that fail in Next (one email each)
<!-- Run each call below in its own Next email: one of them in a combined email
would stop the whole preview or block the save. -->
<!-- email 1: expect that the save is rejected (HTTP 400) -->
%%=GUID("x")=%%
Differs from official docs
- It works in Next although the docs say it does not. The official availability table marks
GUIDas unsupported in Marketing Cloud Next. In a Next email every call produced a new 36-character identifier. Card
Availability & differences
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | Yes, from API 68.0 |
GUID behaves the same on both: 36 characters, hyphens at 9, 14, 19 and 24, no braces, a new value per call. Comparing a GUID with == differs, because == ignores case in Next and respects it in Engagement (see IIf). Compared 2026-11-23 by rendering the same calls in a Marketing Cloud Next email.
See also
- Length — check the 36 characters
- Substring — cut the value into groups
- Lowercase — normalise the case
- Official reference