Syntax

Attribute.GetValue(name)
1 argument

Description

The global Attribute object provides access to subscriber attribute (profile attribute) values for the current recipient. It requires Platform.Load("Core", ...) before use.

Attribute.GetValue(name) is available in CloudPages: after the Core library is loaded, the Attribute object exists and GetValue executes and returns a string. When there is no recipient/attribute context (for example an anonymously published CloudPage GET), it returns an empty string rather than throwing. In email, triggered send, and personalized (recipient-aware) contexts it returns the actual attribute value.

In non-recipient CloudPage scenarios where you need subscriber data, read it from a Data Extension via Platform.Function.Lookup() / Platform.Function.LookupRows(), or use Platform.Recipient.GetAttributeValue (equivalent to Attribute.GetValue).

The AMPscript parallel is AttributeValue() (different language); SSJS uses Attribute.GetValue(name).

Example

Platform.Load("Core", "1.1.1");

var firstName = Attribute.GetValue("FirstName");
var city      = Attribute.GetValue("City");

if (firstName) {
    Write("<p>Hello, " + firstName + "!</p>");
}

See Also