Using Enhanced 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 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 Enhanced JavaScript as this approach ensures consistent results compared to company attributes which requires additional configuration.

Syntax

  • If a user attribute contains text, numbers, lists, or dates, use single ('') or double ("") quotes. For example,
    '{{email}}', '{{signed_up_at}}', "{{locale_code}}"

    • If the user attribute is bound to a multi-line text question, use backticks (``), not single quotes. (Use the key to the left of the "1" on the QWERTY keyboard.)

    • Backtick quotes should be placed before and after the curly braces. For example, `{{answer}}`.

  • To insert variables, use double braces. For example, userFeedback = {{user_nps_feedback}};

  • To hold the parameters (inputs), use parentheses when you define a function. For example, use openForm(`{{er_nps_score}}`);