If you would like to track the specific set of pages, Regex can be used for that as well. Look at the examples given below


Example 1:


https://www.example.com/shop/men/pants/

https://www.example.com/shop/men/coats/

https://www.example.com/shop/men/tshirts/



In the above example, multiple categories fall under “Men” 

If you would like to track all the URLs under Men category then you may use below Regex pattern


https?:\/\/(www.)?example.com\/shop\/men\/.* 


Regex Easy Reference:


Character

Expression

Example

? (question mark)

Once or none

Https? = it will track both http and https 


(www.)? = it will track the URLs with www at the front even if it is not present as (?) refers to zero or none

 . (dot)

Any character be it alphabets, numeric and special characters except line break


Https?. = any one character that comes after http or https will be tracked 

For eg: 

1)https: 

2)https

3)https&

* (asterisk)

Zero or more times

https?* any character that that is prior to (*) will be considered zero or more times

Example 1:

1)https

1)https?????

2)https??


Example 2:

https.* = It will track anything that comes after https as (.) refers to any character and (*) refers to zero or more times




 [0-9]

Any numerical character between 0 to 9 will be considered

Example:

www.example.com/[0-9]*


Will track below URLs


www.example.com/1234

www.example.com/54

www.example.com/787


If the asterisk not given at last then only one numeric letter will be considered as below

www.example.com/4

www.example.com/5

www.example.com/8


[a-zA-Z]

Uppercase and Lowercase alphabets between A to Z

Example:

www.example.com/[a-zA_Z]*


Will track below URLs

www.example.com/aBcD

www.example.com/Boys

www.example.com/Gals



Similarly, 

https://www.example.com/shop/women/pants/

https://www.example.com/shop/women/coats/

https://www.example.com/shop/women/stolls/


Regex pattern given below will track all the categories fall under “Women”


https?:\/\/(www.)?example.com\/shop\/women\/.* 


Above suggested Regex pattern will help you to track categories that fall under men and women by running two different experiments 


Example 2:


Now, Let us see different scenario where you would like to track all categories that fall under men, women & children in a single experiment 


Using Regex pattern we can track all categories that fall under Men, Women & Children in a single experiment

 

Regex Pattern:


https?:\/\/(www.)?example.com\/shop\/(men|women|children)\/.* 


The above-given regex pattern will track below type of URLs 


https://www.example.com/shop/men/pants/

https://www.example.com/shop/men/coats/

https://www.example.com/shop/men/tshirts/

https://www.example.com/shop/women/pants/

https://www.example.com/shop/women/coats/

https://www.example.com/shop/women/stolls/

https://www.example.com/shop/children/shorts/

https://www.example.com/shop/children/trousers/

https://www.example.com/shop/children/tracks/


Pipe ( | )  symbol in regex Indicates that a match can be one of the two terms on either side of the pipe.


Example 3:


In above examples, we tracked URLs based on alphabets, Now we can see an how to track dynamic URLs that have numerical, alphanumerical & special characters in it.


https://www.example.com/shop/men/pants/orderid-9871.html

https://www.example.com/shop/men/pants/orderid-13243.html

https://www.example.com/shop/men/pants/orderid-234656.html

https://www.example.com/shop/men/pants/orderid-7866344.html


Regex Pattern:


https?:\/\/(www.)?example.com\/shop\/men\/pants\/orderid-[0-9]*.html


See the above table for reference


Example 4:


In e-Commerce sites, URLs will be dynamic and it will be alphanumerical and in some cases, special characters too will be included in the URLs. In these scenarios below regex pattern will be helpful to track those type of URLs


Regex Pattern:


https?:\/\/(www.)?example.com\/shop\/categories\/orderid/[a-zA_Z0-9=/+]*.*


Above given regex pattern will track below type of URLs


https://www.example.com/shop/categories/orderid/abdjdf76383686/ordered.html

https://www.example.com/shop/categories/orderid/shhfhghuretru/purchased.html

https://www.example.com/shop/categories/orderid/6869799800090/shipped.html


Until the orderid, it will follow the pattern. After that, since we have given [a-zA-Z0-9]* which means all the alphanumerical characters will be considered if it exists zero or more times in the URL. If your URL contains special characters then include the special characters inside the square brackets for eg: [a-zA-Z0-9%#] 



Technical Support
Don't see what you're looking for? Just drop us a mail