Using Evaluate JavaScript

Prev Next

JavaScript can be used to add actions to buttons or flow step triggers, allowing you to initiate actions within your application. For example, in banner embeds or flow steps, you can select Evaluate JavaScript (also called "Enhanced JavaScript") as an action to run custom JavaScript code within your app. This allows you to trigger specific behaviors or integrations dynamically.

User attributes vs. Company attributes

We recommend targeting user attributes in Evaluate JavaScript as this approach ensures consistent results compared to company attributes which requires additional configuration.

Syntax

Insert a user attribute with double curly braces, and wrap it in quotes so the result is valid JavaScript:

  • Text, numbers, lists, or dates: use single (') or double (") quotes around the braces. const email = '{{email}}'; const locale = "{{locale_code}}";

  • Multi-line text (for example, an attribute bound to a multi-line text survey question): use backticks (`) instead, because a line break inside single or double quotes breaks the code. The backtick key is to the left of the 1 key on a QWERTY keyboard. const feedback = `{{user_nps_feedback}}`;

  • Passing an attribute to a function in your app: put the quoted attribute inside the function's parentheses. openForm('{{user_nps_score}}');