Expand my Community achievements bar.

Announcement: Calling all learners and mentors! Applications are now open for the Adobe Analytics 2024 Mentorship Program! Come learn from the best to prepare for an official certification in Adobe Analytics.
SOLVED

Using regular expressions in segments

Avatar

Level 1

Hello,
Is it possible to use regular expressions in segments ?
I need to exclude in segments for one dimension all expressions with 13 ou 14 characters (and contain only numbers).
Thanks for your help.
Barbara

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Short answer is no.. Regex is not yet supported in Segments.... that said, even if it was, it wouldn't result in what you are looking for... Segments are just rules to pull back data as tracked and present it... you cannot modify/edit how values are shown with a Segment, only what rows of data are returned....

 

What you are actually looking for is called Classifications.

 

Classifications allow you to create "sub dimensions" essentially, and you can modify the values in those, and Regex is supported.

 

To start, you need to create one or more classifications on your dimension:

Admin > Report Suites

(Choose one or more Suites - make sure the profiles match if you choose more than one)

Edit Settings > Traffic >  Traffic Classifications (for props)

or 

Edit Settings > Conversion >  Conversion Classifications (for eVars)

etc

 

Now, find the item you want to add classifications to from the list, and new (well named) classifications

Jennifer_Dungan_0-1683820404839.png

 

 

Once you have these set up, you can move over the Classification Rule Builder (you can also import classifications, but from the sounds of it, the Rule Builder should be more than sufficient)

Admin > Classification Rule Builder

 

First, add a new Rule Set, and give it an appropriate name

Now, you have to select the suite(s) and the dimension that you made the classifications in...

 

You can add multiple rules, they process in the order they appear, so later rules (if conflicting) will override previous rules.

 

You can see that here you can select Regular Expression, and if you create your rule with groups, you can reference the group in the "To" column... you can also use something like $1$2$3 if you want to concatenate the first three group, or $1$3 if you want to remove content from the middle.

 

There is a single value check in the rule builder, but you can check against a list of items in the "Test Rule Set"

 

Once you are happy with your rules, you can choose a processing lookback window of up 6 months... the initial processing will take up to 24 hours... 

If you need to modify the rules, it will deactivate the rule, and you will have to reactivate the rule and re-process.


For more info on Classifications:
https://experienceleague.adobe.com/docs/analytics/components/classifications/c-classifications.html?... 

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Short answer is no.. Regex is not yet supported in Segments.... that said, even if it was, it wouldn't result in what you are looking for... Segments are just rules to pull back data as tracked and present it... you cannot modify/edit how values are shown with a Segment, only what rows of data are returned....

 

What you are actually looking for is called Classifications.

 

Classifications allow you to create "sub dimensions" essentially, and you can modify the values in those, and Regex is supported.

 

To start, you need to create one or more classifications on your dimension:

Admin > Report Suites

(Choose one or more Suites - make sure the profiles match if you choose more than one)

Edit Settings > Traffic >  Traffic Classifications (for props)

or 

Edit Settings > Conversion >  Conversion Classifications (for eVars)

etc

 

Now, find the item you want to add classifications to from the list, and new (well named) classifications

Jennifer_Dungan_0-1683820404839.png

 

 

Once you have these set up, you can move over the Classification Rule Builder (you can also import classifications, but from the sounds of it, the Rule Builder should be more than sufficient)

Admin > Classification Rule Builder

 

First, add a new Rule Set, and give it an appropriate name

Now, you have to select the suite(s) and the dimension that you made the classifications in...

 

You can add multiple rules, they process in the order they appear, so later rules (if conflicting) will override previous rules.

 

You can see that here you can select Regular Expression, and if you create your rule with groups, you can reference the group in the "To" column... you can also use something like $1$2$3 if you want to concatenate the first three group, or $1$3 if you want to remove content from the middle.

 

There is a single value check in the rule builder, but you can check against a list of items in the "Test Rule Set"

 

Once you are happy with your rules, you can choose a processing lookback window of up 6 months... the initial processing will take up to 24 hours... 

If you need to modify the rules, it will deactivate the rule, and you will have to reactivate the rule and re-process.


For more info on Classifications:
https://experienceleague.adobe.com/docs/analytics/components/classifications/c-classifications.html?... 

Avatar

Community Advisor


Hello Barbara,

Yes, you can use regular expressions in Adobe Analytics segments. To achieve your goal of excluding all expressions with 13 or 14 characters (and containing only numbers), you can follow these steps:

- In the Adobe Analytics Workspace, click on the "Components" tab and select "Segments."

- Click on "Create New Segment."

- Drag the "Dimension" you want to apply the filter to into the "Drop Dimension or Item Here" area.

- From the drop-down menu next to the dimension, select "matches RegEx."

- In the text box, enter the following regular expression: ^(?:\d{13}|\d{14})$

- This regular expression will match strings containing exactly 13 or 14 numeric characters. Since you want to exclude these, make sure to check the "Exclude" checkbox next to the "Dimension" in the segment builder.

- Save the segment with a relevant name and description.

Now you can apply this segment to your reports to filter out those dimensions that meet the specified criteria.

I hope this helps! If you have any other questions, please feel free to ask.

Best regards,

Avatar

Community Advisor

This is incorrect information... regex is not, and has never been available in the  Segment Builder:

 

https://experienceleague.adobe.com/docs/analytics/components/segmentation/segment-reference/seg-oper...

 

 

It might be available in CJA filters, but that is a different tool.

Avatar

Community Advisor

Yes, @Jennifer_Dungan, Sorry for the confusion. 

Here is what @web_analysed509 can try as a workaround:

- Create a new calculated metric using a custom formula that evaluates the length of the dimension value you are interested in.

- In Adobe Analytics Workspace, click on the "Components" tab and select "Calculated Metrics."

- Click on "Create New Metric."

- In the formula field, enter a custom formula that checks whether the length of your dimension (e.g., eVar1) is equal to 13 or 14 characters. The formula might look like this:

- IF(LEN(eVar1) == 13 OR LEN(eVar1) == 14, 1, 0)

- Replace "eVar1" with the appropriate dimension you want to filter.

- Save the calculated metric with a relevant name and description.

- Create a new segment, and use the newly created calculated metric as a filter.

- In the segment builder, drag the "Metric" item into the "Drop Dimension or Item Here" area.

- Choose your newly created calculated metric and set the condition to "equals" and the value to "0."

- Save the segment with a relevant name and description.


Now you can apply this segment to your reports to filter out those dimensions that meet the specified criteria.


Please note that this approach will only work for dimensions that store text values as numbers. Additionally, this method is not as precise as using regular expressions, but it should provide a suitable workaround for your use case.

Avatar

Community Advisor

It would still be easier, and more reliable to use Classifications... even setting a value of "true" for matching, and "false" for not matching,, then create a segment for:

 

classification equals "false"