Skip to content

Targeting and segments ​

Targeting decides who sees a tour, announcement or survey. The backend applies it before content reaches the browser, so hidden content is never sent.

One model for tours, announcements and surveys ​

Every tour, announcement and survey has the same three parts. Each part is optional, and they all have to match.

PartWhat it doesWhere it is checked
AudienceOnly these segments (a visitor in any of them), Never these segments (a visitor in any of them never sees it), optional inline conditions, and new vs returning visitors.Server, before content is sent.
PagesOnly on these pages and Never on these pages, each a list of rules.The visitor's browser, on every page change.
ScheduleA start and end time. Tours only: announcements set theirs in the Schedule section of their Settings tab, surveys have none.Server.

Leaving a part empty means "no restriction": no segments and no rules show it to everyone, everywhere.

Page rules ​

Each rule has an operator and a value. A page is included when it matches any include rule (or when there are none) and matches no exclude rule.

OperatorMatches
is exactlyThe path equals the value.
starts withThe path starts with the value.
containsThe path contains the value.
matches pattern* stands for one path segment, ** for any depth: /projects/*/settings, /docs/**.
matches regexA regular expression on the path. An invalid expression never matches.

The query string and #hash are ignored unless you tick query or #hash on the rule. The builder has a Test a URL box that shows whether a URL would match.

Turn the SDK off on some pages ​

Use the excludePaths option when nothing from JustOneCX should show on a page (an admin area, a preview frame): it hides chat, tours, announcements, surveys and What's new there. To turn off one kind everywhere on a page, use disableTours, disableAnnouncements or disableSurveys.

A second copy of the SDK on the same page (a tag manager plus the npm package, for example) logs one warning and stays inactive, so chat and tours do not appear twice.

Where the data comes from ​

  • identify sets user traits such as plan and role.
  • group sets account traits.
  • track records events.

An anonymous visitor who never calls these still matches page rules, schedules and new-vs-returning rules. Segments and inline conditions need trait data. An account-level segment never matches a visitor who has not called group().

Create a segment ​

  1. Open Segments in the dashboard.
  2. Define conditions on the traits you send with identify and group.
  3. Use the segment in a tour, announcement or survey.

What a segment can use ​

AttributeWhat it reads
Role, PlanThe role and plan traits you send with identify.
Custom traitAny trait you send with identify (enter its key).
Account traitA trait you send with group (enter its key).
IdentifiedWhether the person has a user id (called identify) or is anonymous.
Signup date, First seen, Last seenWhen the person (or account) was first and last seen.
Account MAUDistinct active users of the account in the last 30 days.
Performed event / Never performed eventWhether the person sent an event (from the browser or your server), at least N times, optionally in the last N days.
Completed tour / Dismissed tourWhether the person finished or dismissed a tour (enter its key or id).
Answered survey / Saw announcementWhether the person answered a survey or saw an announcement (key or id).
Opened chat, Chat ratingWhether the person started a chat, and whether they rated one at most N out of 5.

A segment that measures accounts can only use the account-level attributes (traits, signup/first/last seen, MAU). The rest describe one person.

What is not a segment attribute: the page the visitor is on, their device, language and country. Those only exist in the browser, so they are checked there: use page rules for the current page and the SDK's context options for the rest. A segment is decided on the server before content is sent, so it cannot depend on them.

Groups ​

A segment is made of groups. Conditions inside a group combine with the group's Match all (every condition) or Match any (at least one). With two or more groups, the top-level choice decides how the groups combine: all groups or any group. This covers "(role is admin and plan is pro) or plan is free" without nesting further.

Segments made before groups existed were converted when you upgraded: a chain of AND conditions became one group, and a chain with OR was split at each OR into groups joined by any group. The old chain was evaluated strictly left to right, which groups cannot copy exactly, so check a segment that mixed AND and OR.

Operators ​

Each condition compares one attribute with a value. Which operators you can pick depends on the attribute.

OperatorMeaning
equals / does not equalExact match (a date compares the day).
contains / does not containText contains the value, ignoring case.
greater than / less thanNumbers, or dates for the signup date.
betweenFrom and to, both included.
is set / is not setThe trait has a value / has none (an empty text counts as none).
within last N days / not within last N daysThe signup date is that recent / older.

Negative operators match people who have no value. "Plan does not equal pro" includes someone with no plan at all. Use is not set when you want to target people with a missing value on purpose, and is set to require one. "Account MAU less than 5" includes accounts and users with no activity, because they have an MAU of 0.

Keep traits fresh ​

Traits merge, so call identify and group on every page load. If you need targeted content to show right after a trait changes, await identify(...) and then call init() again.

JustOneCX