Skip to main content

Advanced Targeting Conditions

Overview of Promolayer's advanced targeting conditions, including regex URL matching, page title, CSS elements, cookies, and JavaScript variables, and the plans each one requires.

You can use advanced targeting conditions in addition to basic URL matching. The plan required depends on the condition (see "Notes").

How it works

Add one of the conditions below as a target or exclusion rule, in addition to the standard URL match rules described in "Page Targeting (URL): Overview".

Options

Condition

Description

URL matches a regular expression

* Pro plan and above

Show or hide based on a regex pattern matched against the page URL

Page title contains

* Pro plan and above

Show or hide based on a string contained in the page's title

Element matches a CSS selector

* Plus plan and above

Show or hide if an element matching a given selector exists on the page (e.g. an element with the "header" class)

Element has a CSS class

* Plus plan and above

Show or hide if an element has a specified CSS class — see "Show a popup when an element has a specific CSS class" for a walkthrough

Element's CSS property has a value

* Plus plan and above

Show or hide if an element's CSS property matches a specified value

Element has an attribute

* Plus plan and above

Show or hide if an element has a specified attribute

Cookie is present

* Plus plan and above

Show or hide based on whether a specified cookie exists

JavaScript global variable is present

* Plus plan and above

Show or hide based on whether a specified JavaScript global variable exists

Usage examples

URL matches a regular expression

Show it on every product page

No need to list every product URL — show a "free shipping" notice across all product pages.

- Condition: "URL matches a regular expression"

- Value: ^/products/.* (example for product URLs like /products/product-name)

Page title contains

Show it only on sale pages

Even if sale page URLs aren't consistent, show a popup wherever the page title contains "Sale."

- Condition: "Page title contains"

- Value: Sale

Element matches a CSS selector

Show it only on "out of stock" product pages

Automatically detect the out-of-stock badge instead of listing affected products one by one.

- Condition: "Element matches a CSS selector"

- Value: the CSS class used for the badge (see "Show a popup when an element has a specific CSS class" for how to find it)

Element has a CSS class

Show it only when a specific tab is open (JS-only FAQ pages)

On FAQ pages that swap tabs without changing the URL, show a coupon only while a specific tab is active.

- Condition: "Element has a CSS class"

- Value: the CSS class applied to the active tab

Element's CSS property has a value

Avoid overlapping with other popups

Skip showing this popup while another popup or modal is open.

- Condition: "Element's CSS property has a value"

- Value: property name (e.g. display) and value (e.g. block)

Element has an attribute

Use a theme-specific setting to target a page

Some themes track things like stock status using a data attribute instead of a CSS class.

- Condition: "Element has an attribute"

- Value: attribute name and value

Cookie is present

Show it only to visitors from a partner link

If your partner link sets a cookie, show an exclusive offer only to those visitors.

- Condition: "Cookie is present"

- Value: cookie name

JavaScript global variable is present

Use your own site's data, like membership tier

If your membership system stores tier info in a JavaScript variable, target specific members with it.

- Condition: "JavaScript global variable is present"

- Value: variable name and value

Notes

  • "URL matches a regular expression" and "Page title contains" are available on the Pro plan and above.

  • Element, CSS class, CSS property, attribute, cookie, and JavaScript global variable conditions are available on the Plus plan and above.

  • Element, class, CSS property, and attribute conditions are evaluated based on the state of the page at the moment a trigger fires. A popup does not appear just because a condition changes later — conditions are only checked when a trigger fires. To show a popup right after a specific action (for example, when a video finishes playing or a tab is switched), use a custom trigger (JavaScript) instead.

  • "Element's CSS property has a value" matches only when the value exactly equals the value the browser actually applies (the computed style). Partial matches and the "*" wildcard (any value) are not supported.

  • If you need help setting up a specific condition, please contact our support team.

Did this answer your question?