Launch Brevz Application

Targeting users with notificiations

Learn to use segment with notifications


Overview

This topic explains how to use a segment from the segment tab to control which subscribers receive a notification depending on predicates and rules.

Subscribers are visitors who have enabled their browser to send them notifications.

You can use the Segment tab to create targeting rules for testing, promotions, to partition your visitors according to some attributes.

You can target visitors of your application based on email addresses, timezone, everything that can be uniquely identified.

Targeting users from attributes

Brevz let you target segment of visitors based on attributes by constructing a predicate with multiple rules.

Each rule hase three parts:

  • A param, which defines the visitor's param used to evaluate the rule.
  • An operator, which will describe the type of predicate operation to perform.
  • A value, which will be tested against the visitor's param using the operator.

Here is an example to target all visitors who have an email ending with gmail.com.

Targeting Gmail example

Operators

Brevz supports the following operators:

Name /
Type
Description
contains

string

The contains predicate evaluates as true if the referenced element is defined and has a value whose string representation contains the exact sequence of characters given by the predicate object's value member.
defined

any

The defined predicate evaluates as true if the referenced element exists within the target context. Values are not needed.
Not on stable yet.

ends

string

The ends predicate evaluates as true if the referenced element is defined and has a value whose string representation ends with the exact sequence of characters given by the predicate object's `valuej member.

in

string | number | boolean

The in predicate evaluates as true if the referenced element specifies a value exactly equal to one of the value member.

less

number | date | duration

The less predicate evaluates as true if the referenced element is defined and specifies a number whose value is less than that specified by the predicate object's value member.

The less predicate evaluates as true if the referenced element is defined and specifies a date by the RFC 3339 (example: 2030-04-12T23:20:50.52Z) whose value is less than the date specified by the predicate object's value member.

The less predicate evaluates as true if the referenced element is defined and specifies a duration by the ISO 8601 (example: PT15M for a duration of 15 minutes) whose value added with the current date is less than the date specified by the predicate object's value member.

matches

string

The matches predicate evaluates as true if the referenced element is defined and has a value whose completely string representation matches the regular expression provided by the predicate object's value member.

Each value member MUST be a regex.
Not on stable yet.

more

number | date | duration

The more predicate evaluates as true if the referenced element is defined and specifies a number whose value is greater than that specified by the predicate object's value member.

The more predicate evaluates as true if the referenced element is defined and specifies a date by the RFC 3339 (example: 2030-04-12T23:20:50.52Z) whose value is greater than the date specified by the predicate object's value member.

The more predicate evaluates as true if the referenced element is defined and specifies a duration by the ISO 8601 (example: PT15M for a duration of 15 minutes) whose value added with the current date is greater than the date specified by the predicate object's value member.

starts

string

The starts predicate evaluates as true if the referenced element is defined and has a value whose string representation begins with the exact sequence of characters given by the predicate object's value member.

type

any

The type predicate evaluates as true if the referenced element exists and specifies a value whose value type is equal to that specified by the predicate's value member.

The value member MUST specify one of: number, string, boolean, object, array, null, undefined.
Not on stable yet.

undefined

any

The undefined predicate evaluates as true if the referenced element does not exist within the target context.
Not on stable yet.

Built-in attributes

Brevz' visitors got some built-in attributes.

Name Example Description

key

"58ad6e92-eb78-4245-8b07-ef366a50f087" Required. This should be unique for each user.

firstname

"Jane"

lastname

"Doe"

email

"jane.doe@domain.ltd"

timezone

"Europe/Paris" Instead of a country, we advise you to provide a timezone

We do not hydrate build-in attributes
You have the fields to fill, it's depending on you if you want to fill these fields or not. If you want to target visitors based on these attributes, you must supply their values with our SDK userData functions.

Custom attributes

In addition to the built-in attributes, you can add your own attributes to target your visitors based on these attributes.

Do not use the same key as built-in attributes
If you use the same keys as the built-in attributes it will cause problems on the targeting engine, you should avoid using the same keys.

Here is an example to target all visitors who have the custom attribute github_role with either maintainer or admin. The custom attribute must be set like this on the client-side:

custom_data.ts
brevzSDK.userData.setCustomData('github_role')('maintainer');

Targeting custom example

Anonymous users

A user is considered anonymous as long as his key has not been defined manually by a setKey. This represents a visitor that you are not able to link to one of your users. Anonymous users do not appear in the advanced statistics & it is not possible to search with them.

As soon as you defined a key for a visitor with the userData.setKey the visitor won't be an anonymous user anymore.