Use JavaScript APIs to define and manage attributes for users and pageviews.
Important
All JavaScript APIs in Optimize must be wrapped in a .ready() callback to run properly.
The Optimize attribute APIs let you define custom data for targeting, segmentation, or machine learning — and give you full control over creating, retrieving, or deleting those attributes. Depending on scope, attributes can persist across sessions or apply just to the current visit.
setAttributes()
Define one or more attributes on either the user or pageview scope.
var scope = 'user'; // or 'pageview'
var attributes = {
planType: 'starter',
device: 'mobile'
};
intellimize.setAttributes(scope, attributes);Example only: You can define any custom name/value pairs — e.g., planType, device, or your own terms.
- Attribute names must be 40 printable ASCII characters or fewer, and can’t include
= - Values must be strings — Optimize will try to coerce booleans and numbers, but string formatting is safest
How attributes are used:
- Stored on the client side
- Sent to Optimize as contextual data alongside views and goal events
- Displayed in the dashboard for configuration and machine learning
getAttributes()
Retrieve a subset of previously stored attributes by name.
var scope = 'user'; var names = ['myName', 'myName2']; var attributes = intellimize.getAttributes(scope, names);
Returns: An object with name/value pairs that match the names provided.
Example output: {myName: 'myValue'}
getAllAttributes()
Retrieve all stored attributes for a given scope.
var scope = 'user'; var attributes = intellimize.getAllAttributes(scope);
Returns: All name/value pairs stored under that scope.
Example output: {myName: 'myValue'}
deleteAttributes()
Remove one or more named attributes from a given scope.
var scope = 'user'; var names = ['myName']; intellimize.deleteAttributes(scope, names);
Behavior: Attributes not present in storage will be skipped with no error.
deleteAllAttributes()
Clear all attributes stored under a specified scope.
var scope = 'user'; intellimize.deleteAttributes(scope);
Behavior: Removes every attribute tied to the given scope.