Skip to main content

Show a popup based on a JavaScript global variable

How to use Promolayer's JavaScript global variable condition to create AND-logic display rules, with an example using the built-in scroll percentage variable.

Promolayer lets you use JavaScript global variable values as conditions, enabling fine-grained display control that goes beyond standard trigger settings.

⚠️ This feature is available on the Pro plan and above.

When to use this

This is useful when you want to show a display only when multiple conditions are all met (AND logic).

  • Show only after the user has scrolled 100% AND been inactive for 30 seconds

  • Show only to users who have performed a specific action

How to set it up

  1. Open the Rules tab and go to "Which pages to show on."

  2. Select "Multiple URLs & advanced targeting."

  3. Add the "Has a JavaScript global variable" condition.

  4. Enter the variable name and value.

Promolayer's built-in variables

Variable

Description

Example value

promolayerObj.currentScrollPercent

Current scroll percentage (%)

100

Example: scroll 100% + 30 seconds of inactivity

  1. Set only the "Inactivity trigger (30 seconds)" trigger.

  2. Add the "Has a JavaScript global variable" condition.

  3. Variable: promolayerObj.currentScrollPercent, Value: 100

The popup will appear only when the user has scrolled to 100% of the page AND been inactive for 30 seconds.

Did this answer your question?