Sometimes membership files are missing categories, which makes it trickier to create segment rules. For example, a member file might have a column for cost centres, with values ranging from 0 to 9999. In this case you may want to segment content based on a range of cost centres. There are two ways to achieve this:
- Include a calculated column in the member file with cost centre ranges (i.e. 0-9, 10-99, 100-999, 1000-9999) and create segment rules based on these categories.
- You can use the ‘matches the expression’ rule within Segment Manager to specify a numerical range for your segment. The expression here is a regular expression (sometimes shortened to regex). A regular expression is a way to describe a pattern. The rest of the article describes this approach.
Regular expressions for number ranges work like this:
[0-9] will find all values from 0 to 9
[0-9][0-9] will find all values from 00 - 99
[0-9][0-9][0-9] will find all values from 000 - 999
[0-9][0-9][0-9][0-9] will find all values from 0000 - 9999
Each [0-9] defines the range for each digit in order, e.g. if your number is two digits long, the first set of square brackets [0-9] will define the range of the first digit in your number, the second set of square brackets [0-9] will define the range of the second digit of your number - and this logic continues with the more digits you add.
Now if you want to define the range more specifically, you can adjust the numbers within the square brackets. For example:
[5-9] will find all values between 5 and 9.
[5-9][0-9] will find all values between 50 and 99.
[5-9][0-9][0-9] will find all values between 500 and 999.
[5-9][0-9][0-0] will find all values ending in 0 between 500 and 999, e.g. 510, 520, 530 and so on…
[5-9][0-0][0-0] will find all values ending in 00 between 500 and 999, e.g. 500, 600, 700, 800, 900
Real life example:
A client wants to set up two segments:
- One segment for cost centres in the range 0 - 1999.
- Another segment for cost centres in the range 2000 - 9999.
What you need to input:
- For segment 1, the field is Cost Centre (ent), the rule is Matches the Expression and the value is [0-1][0-9][0-9][0-9]
- For segment 2, the field is Cost Centre (ent), the rule is Matches the Expression and the value is [2-9][0-9][0-9][0-9]
Once you’ve inputted the expression into Segment Manager, the number of members in the segment should update live in front of you. Please do a sense check with your client to check if those values are correct, and if not, attempt to update your expression.
NOTE: don’t forget that you can combine multiple rules within Segment Manager if you need more specific segmentation!
If you want to learn more about regular expressions for numerical ranges, this article (external link) can give you more examples.
Please sign in to leave a comment.