Analytics
2.1K members online now
2.1K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

GA Regex for exclusion

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm trying to set up a regex that that follows these rules.

 

This is for a URL that starts with:  /helpme

 

I want it to include anything after "helpme" as long as it's before the next "/".  I do NOT want to capture anything after the following "/".  

 

so it will include:  

/helpme

/helpmeplease

/helpmenow

 

but it would not include:

/helpme/gibberish

/helpmeplease/gibberish

 

This is a time-sensitive issue so any quick responses are appreciated.  Thank you!

1 Expert replyverified_user

Re: GA Regex for exclusion

Top Contributor
# 2
Top Contributor
Untested, but you can do a regex 'not this character' like [^/], and it could be repeated to the end of the term $, so pulling it all together, try:

^/helpme[^/]*$

which means start with /helpme
followed by zero or more instances of 'not /'
until the end of line
Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Re: GA Regex for exclusion

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hmm - I gave it a try, but it didn't work.

Re: GA Regex for exclusion

Top Contributor
# 4
Top Contributor
This does work for me... I tested
^/webmastertools/[^/]*$

and it returned
/webmastertools/

but not
/webmastertools/wt-sites/
etc.
Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.