Targeting
Targeting rules can be used to grant features to specific user groups, incrementally roll out features for monitoring, or create and test different feature configurations by using multiple variables.
Be sure to check out our advanced targeting documentation which covers topics like:
Each targeting rule has four parts that must be set, and one optional item, as seen here:
-
The current targeting status.
This is what defines if the rules will be used to deliver a variation of a feature to users. If it is off, no users within the environment will receive the feature at all, regardless of the targeting rules.
-
A unique rule name.
This name can be used for debugging and informational purposes when understanding why certain users received certain variations.
-
The Rule Definition.
This is the logic of who will receive the specified variation, based on various properties of the user (e.g. User ID, User Email, Audience, etc). The many ways to create a definition will be outlined below.
-
What users will be Served
This is what defines what a user who fills the rule will receive. Different rules may receive different variations. Additionally, a random distribution of variations can be set.
-
(Optional) The Schedule of the Feature*
When set to the default (None), this rule will be enabled when the environment is enabled. However, a specific date/time can be set, as well as a gradual rollout of this Feature to the target.
Example: Targeting specific users.
Let's say for example there is a brand new feature that is meant to only roll out to internal QA users for the time being. There > are numerous ways to achieve this, however for this example only known user ids or emails will be used.
In this example, the users with a user ID of "john" and "victor" will receive the variation of "Variation ON" of this feature on the Development Environment. This type of direct user targeting is great for numerous things such as adding users to QA versions of a feature, inviting beta users to a feature, or simply targeting your personal user ID for development purposes.
Rule Definition
Each property has a type that has its own set of comparators available to it.
Operator | Type | Action |
---|---|---|
is | string, number, boolean | exact match on one of the values |
is not | string, number, boolean | exact match on none of the values |
contains | string | substring match |
does not contain | string | substring does not match |
exists | string, number, boolean | null check |
does not exist | string, number, boolean | null check |
equals, does not equal | number | math comparison |
greater than, less than | number | math comparison |
less than or equal to, greater than or equal to | number | math comparison |
Each definition can have AND operations as well, allowing for more complex combinations of properties:
Note: Disabling an environment's rules will remove all users in that environment from the Feature and users will receive the code defaults.
Targeting Rule Evaluation Order
Often during development, developers might want to create specific targeting rules which target themselves as they work on a feature. Or, a larger feature with many personalized variations could have a lot of targeting rules.
Sometimes, you want to make sure a user doesn't get caught up in an earlier defined targeting rule. Or, you would like to add a new variation to serve a specific target.
User Targeting evaluates rules in top-down order. A User may fall into multiple targeting rules, however, they will see the first Variation that they match for the given Environment.
This situation allows you to group specific users into seeing a Variation, for example:
- Meet our user Victor, he lives in Canada and has a @devcycle.com email address. We do not want him, or other @devcycle.com users, to see our Secret Getaway Feature.
- Victor has a neighbor, John that doesnβt have a @devcycle.com email address. We want all our other Canadian users to see our Secret Getaway Feature.
- Victor also has several friends that live in Norway, and we want to show all our users in Norway the Secret Getaway Feature.
In this situation, hereβs how we can set up our Targeting Rule for the Secret Getaway Feature.
First, we define our first Targeting Rule that will target Users in Canada with email addresses containing @devcycle.com to NOT see the Secret Getaway Feature.
Then we can add a second Targeting Rule by clicking the βAdd Targeting Rule" button.
Lastly, we want to make sure that other Users in Canada (i.e. those without @devcycle.com emails) and all Users in Norway DO see the Secret Getaway Feature.
The above will then satisfy the requirements of the defined situation.
Managing a Targeting Ruleβ
From the CLIβ
Once you have installed and authorized the CLI, select your relevant organization then run the following command:
dvc targeting get
You will be prompted to select a feature and environment.
If successful you will receive a response which resembles the following (which selected a feature named feature-a
and the Development
environment):
ββ Development
ββ status
ββ enabled
To enable a targetting rule for a feature, you will follow a similar process to above but using the command
dvc targeting enable
If successful you will receive a response which resembles the following (for enabling the targeting rules for the Staging
environment of a feature):
ββ Staging
ββ status
β ββ enabled
ββ rules
ββ 1. All Users
ββ definition
β ββ All Users
ββ serve
ββ Variation On
To enable a targetting rule for a feature, you will follow a similar process to above but using the command
dvc targeting disable
If successful you will receive a response which resembles the following (for disabling the targeting rules for the Staging
environment of a feature):
ββ Staging
ββ status
β ββ disabled
ββ rules
ββ 1. All Users
ββ definition
β ββ All Users
ββ serve
ββ Variation On
From the Dashboardβ
Targeting rules can be seen in the individual feature page by selecting the relevant environment under Users & Targeting
in the Manage Feature π© menu on the left hand side of the screen.
From here you will be able to enable or disable the specific targetting rule by clicking the Targeting ON
toggle.
Creating a Targeting Ruleβ
Looking to use DevCycle to help you QA a new feature? Be sure to check out Self-Targeting.
From the CLIβ
Once you have installed and authorized the CLI, select your relevant organization then run the following command:
dvc targeting update
You will be prompted to select a feature, environment and what you would like to update (status or targets). For this case you should select only targets
.
You should then select Add Targeting Rule
and will be prompted to define a Name, Variations to serve and a filter. For this case, if you have not yet created any filters, you should select Add Filter
.
Here you will be prompted to select a definition of all (for all users), user (to target a specific user based on an identifier like email, country, etc.) or audienceMatch (see Audiences).
Looking to reuse an audience in user targeting for features? Be sure to check out the our documentation explaining how to create and manage Audiences via our API or within the DevCycle dashboard.
Once you have chosen your relevant definition select Continue
(twice) when prompted. If successful you should see a flow which resembles the following (which represents added a new targeting rule to feature-a
in the Staging Environment
for any users with the email address that contains devcycle
and will serve them a variation named New Variation
):
? Which feature? feature-a
? Which environment? Staging (staging)
? Which fields are you updating targets
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
ββ definition
β ββ All Users
ββ serve
ββ Variation On
? Select an action: Add Targeting Rule
? Name: New Targeting Rule
? Variation to serve New Variation (new-variation)
π€ No existing Filters.
? Select an action: Add Filter
? Type for definition user
? Subtype for definition email
? Comparator for definition contain
? List of comma separated values for definition: devcycle
π€ Manage your filters
π€ Current Filters:
ββ Email
ββ contains
ββ devcycle
----------------------------------------
? Select an action: Continue
π€ Manage your filters
π€ Current Filters:
ββ Email
ββ contains
ββ devcycle
----------------------------------------
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ contains
β ββ devcycle
ββ serve
ββ new-variation
----------------------------------------
? Select an action: Continue
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ contains
β ββ devcycle
ββ serve
ββ new-variation
----------------------------------------
ββ Staging
ββ status
β ββ enabled
ββ rules
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ contains
β ββ devcycle
ββ serve
ββ New Variation
To enable a targetting rule for a feature, you will follow a similar process to above but using the command
dvc targeting enable
If successful you will receive a response which resembles the following (for enabling the targeting rules for the Staging
environment of a feature):
ββ Staging
ββ status
β ββ enabled
ββ rules
ββ 1. All Users
ββ definition
β ββ All Users
ββ serve
ββ Variation On
From the Dashboardβ
On the features dashboard page, select Users & Targeting
from the left hand menu and choose which environment it should apply to. If a feature is toggled ON
for an environment, the rules defined within the environment will be followed.
Once the targeting rule is defined, the next step is to determine what Variation users targeted by this rule should receive. Note: The available variations will be determined by the chosen Feature Type, however, these can be modified and more variations can be added at any time.
To choose the Variation for this targeted audience, use the "Serve" dropdown and choose the desired variation. When the environment is enabled, and if a user fulfills the targeting rule, they will then be served that variation and its associated variable values.
Updating A Targeting Ruleβ
From the CLIβ
Once you have installed and authorized the CLI, select your relevant organization then run the following command:
dvc targeting update
You will be prompted to select a feature, environment and you should ensure that targets
are selected when asked which fields you are updating.
From here select Edit Targeting Rule
, chose the relevant targetting rule you would like to update.
You will then be prompted to change the Name and Variation to Serve (click enter if you would like to keep these the same).
Next you will be prompted to Add, Edit or Remove Filters (known as Definitions on the dashboard). Click continue of you would not like to change these or select the appropriate option for your situation.
If successful you will receive a response which resembles the following (which represents updating a targeting rule named New Targeting Rule
on the Staging Environment
for feature-a
to show Variation Off
to impact any users with the email address that does not contain devcycle
.):
? Which feature? feature-a
? Which environment? Staging (staging)
? Which fields are you updating targets
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ contains
β ββ devcycle
ββ serve
ββ New Variation
? Select an action: Edit Targeting Rule
? Which Targeting Rule would you like to edit? New Targeting Rule
? Name: New Targeting Rule
? Variation to serve Variation Off (variation-off)
π€ Manage your filters
π€ Current Filters:
ββ Email
ββ contains
ββ devcycle
? Select an action: Edit Filter
? Which Filter would you like to edit? {"type":"user","subType":"email","comparator":"contain","values":["devcycle"]}
? Which fields are you updating
π€ Manage your filters
π€ Current Filters:
ββ Email
ββ contains
ββ devcycle
----------------------------------------
? Select an action: Continue
π€ Manage your filters
π€ Current Filters:
ββ Email
ββ does not contain
ββ devcycle
----------------------------------------
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ does not contain
β ββ devcycle
ββ serve
ββ variation-off
---------------------------------------
? Select an action: Continue
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ does not contain
β ββ devcycle
ββ serve
ββ variation-off
----------------------------------------
ββ Staging
ββ status
β ββ enabled
ββ rules
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ does not contain
β ββ devcycle
ββ serve
ββ Variation Off
Other update actions from the CLI include:
- Reordering a Targeting Rule
- Reordering a Filter (known as definition in the CLI)
From the Dashboardβ
Targeting Rules can be updated on the dashboard anytime by changing the relevant input for the environment in question and click the Save
button in the upper right-hand corner of the screen.
Reordering Targeting Rules
In these cases, you can very simply reorder any Targeting Rule by clicking the arrows on the side of the rule and moving it up or down.
Saving this Feature will then cause the next evaluation of a variable for all users to respect the new targeting order (after the config has been updated for client-side SDKs).
Deleting a Targeting Ruleβ
From the CLIβ
Once you have installed and authorized the CLI, select your relevant organization then run the following command:
dvc targeting update
You will be prompted to select a feature, environment and you should ensure that targets
are selected when asked which fields you are updating.
Select Remove Targeting Rule
from the options presented and chose the reelvant Targeting rule you would like to delete. Click continue.
If successful you will receive a response which resembles the following (which represents removing a targeting rule named New Targeting Rule
on the Staging Environment
for feature-a
.):
? Which feature? feature-a
? Which environment? Staging (staging)
? Which fields are you updating targets
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ does not contain
β ββ devcycle
ββ serve
ββ Variation Off
? Select an action: Exit (Discard changes)
ββ Staging
ββ status
β ββ enabled
ββ rules
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ does not contain
β ββ devcycle
ββ serve
ββ Variation Off
@andrewdmaclean β /workspaces/devcycle-docs (main) $ dvc targeting update
? Which feature? feature-a
? Which environment? Staging (staging)
? Which fields are you updating targets
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
β ββ definition
β β ββ All Users
β ββ serve
β ββ Variation On
ββ 2. New Targeting Rule
ββ definition
β ββ Email
β ββ does not contain
β ββ devcycle
ββ serve
ββ Variation Off
? Select an action: Remove Targeting Rule
? Select the Targeting Rule you would like to delete: New Targeting Rule
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
ββ definition
β ββ All Users
ββ serve
ββ Variation On
----------------------------------------
? Select an action: Continue
π€ Manage your Targeting
π€ Current Targeting Rules:
ββ 1. All Users
ββ definition
β ββ All Users
ββ serve
ββ Variation On
----------------------------------------
ββ Staging
ββ status
β ββ enabled
ββ rules
ββ 1. All Users
ββ definition
β ββ All Users
ββ serve
ββ Variation On
A similar process should be applied for removing filters/definitions
From the Dashboardβ
Select the trash can icon on the right-hand side of the relevant environment targeting rules to delete the rule and click Save
to apply the changes.