Skip to main content

The $alia object

Reference data & perform actions from custom code using the $alia object

Bill Wohlers avatar
Written by Bill Wohlers
Updated this week

The $alia object is a Javascript object that allows you to reference user data and perform actions relating to Alia's current state.

The $alia object is supported in the following places:

  • Custom code elements

  • Custom code actions

  • Expressions (in text & button elements and form submission properties)

How to use the $alia object

You can reference the $alia object like any other variable. For example:

const property = $alia.user.profile.properties["my-property"];
$alia.actions.nextStep();

All the properties that exist on the $alia object are documented below.

$alia.user

Contains info about the user. The shape of this object is:

{
createdAt: string; // ISO format, when the user first visited
shopifyCustomerID: string;
ipAddress: string;
country: string; // ISO 3166-1 alpha-2
market: string; // Shopify market
language: string; // Shopify locale (IETF language tag)
name: string;
phone: string; // only available immediately after signing up
email: string; // only available immediately after signing up
profile: {
properties: Record<string, string>; // contains survey answers, etc.
}
}

Getting a user's answer to a question

You can get a user's answer to a specific question by using the $alia.user.profile.properties object. The key will be the question name (as set in the Question element), and the value will be their answer. If there are multiple answers, they will be joined to a single string using a comma delimiter.

$alia.popup.step(id?: string)

Goes to the step with the given ID. If no ID is provided, goes to the next step.

The step ID can be found by right-clicking on a step in the popup editor and clicking "Copy step ID".

$alia.popup.closePopup()

Closes the popup.

Did this answer your question?