Regular Expressions (RegEx) are advanced search patterns to match multiple URLs by providing conditions. This match type helps in defining a search pattern in which the Experiments should run.
Regex is the most complex form of URL targeting and requires the use of regular expressions. Using different regular expressions, you can target a wide range of pages. This form of URL targeting is the most helpful for targeting multiple pages simultaneously.
Given below are some of the examples in RegEx match type
Example 1: Targeting all the pages in a specific URL
To target all the pages in a URL - https://www.test.com/app/
You can use the regex pattern:
Example 2: Targeting the pages ending with numbers
To target URLs such as
You can use the regex pattern:
Example 3: Targeting the pages with particular word in it
To target the pages in a domain with a particular word such as,
- https://test.com/app1.html
- https://test.com/app2a.html
- https://test.com/app11b.html
- https://test.com/app187b.html
You can use the regex pattern:
Example 4: Targeting either of the pages
To target pages with either of terms in the domain such as,
You can use the regex pattern:
Example 5: Targeting by excluding a group of similar pages
To target all the pages except a page or set of pages with certain string in it such as,
You can use the regex pattern:
By using the above-mentioned regex pattern, you can exclude all the pages with UK string after the /app/ in the domain URL. Some of the pages(example) which will be tracked are
- https://test.com/app/usa/products
- https://test.com/app/australia/products
- https://test.com/app/india/products
Example 6: Targeting complex pages
To target complex set of URLs such as
- https://www.test.com/india/categories/boys/pants
- http://test.com/australia/products/women/tops
- http://www.test.com/brazil/categories/men/shirts
- https://test.com/usa/products/girls/shoes
You can use the regex pattern:
RegEx characters used in the above example are explained as follows
https? - Tracks both http as well as https
(www.)? - Tracks the pages with our without www in the URL
Here, both http://www.test.com and https://test.com will be tracked