Analytics
4.4K members online now
4.4K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Excluding certain URLs with regex

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm a beginner with regex and I'm trying to set up a goal that will INCLUDE thank you pages such as:

 

/Best-Practices-TY-LP.html
/Mobile-TYP.html
/Top-10-Guide-TYP-Jan-2014.html

 

But EXCLUDE our "priority 1" thank you pages that contain the words 'demo', 'contact' or 'trial', such as:

 

/Website-Demo-Request-Thank-You-LP.html
/Website-Contact-Us-Thank-You-LP.html
/SEM-Brand-Demo-Request_TY-LP.html
/Demo-Request_TY-LP.html
/Contact-Sales-Website1-TYP.html
/Trial-TY-LP.html

 

I've come up with a regex to isolate only the P1 pages:
.*(Demo|Contact|Trial).*(TY\-LP|LP\-TY|TYLP|TYP\.|TYP\-|Thank\-You|WhitepaperTY)

 

But now I need something that will include (TY\-LP|LP\-TY|TYLP|TYP\.|TYP\-|Thank\-You|WhitepaperTY) and exclude (Demo|Contact|Trial) so I can identify the rest of our thank you pages in a goal.

 

Since GA doesn't allow the lookahead/behind regex, I'm not sure how to tackle this. I've tried several variations and nothing seems to work. (I can't use the "exclude" dropdown that many have mentioned in other posts because the goals do not have that option. I have to fit it all into a single line of regex.)


Thanks in advance!!

 

p.s. I know our URLs are a mess. I'm working on cleaning that up. But in the meantime, this is what I have to work with. Smiley Happy

 

1 Expert replyverified_user

Re: Excluding certain URLs with regex

Top Contributor
# 2
Top Contributor
You'd have to post a full list of the good and bad urls to let anyone suggest an expression that would work.

You might consider splitting up the list into multiple goals in some logical grouping, making the individual expressions less complicated and more specific.
Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Re: Excluding certain URLs with regex

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Mike,
Thanks for responding! There are over 100 different URLs that make up the include/exclude requirements and I need a regex that will work as new pages are created as well. The examples I provided cover the variations that occur within the URLs, so I'm hoping for a regex that will work across the board.

The examples I provided are the URLs directly off the domain, so there aren't additional directories that make up the URLs, if that's what you're wondering.

My overall need is to have two goals:

Goal 1: includes all "P1" thank you pages (which I've got the regex working for already.)
Goal 2: includes all thank you pages that are NOT the P1 pages (this is what I need help with.)

Thanks!

Re: Excluding certain URLs with regex

Top Contributor
# 4
Top Contributor
Where I was going with my request was to take a different approach to solving the problem. Maybe there is a different pattern that you could look for beyond the ones you identified that does not involve exclusion.

One idea would be to use a segment, which has a lot more flexibility in cascading filters and has the advantage of being changeable without affecting the underlying data.

Another idea is to use a series of view filters to tag pages with a custom dimension value for all 'TY pages', 'not P1 pages', and 'other', then use that custom dimension to determine your goals.

Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Re: Excluding certain URLs with regex

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Ok, I think I follow what you're suggesting. But when I'm setting up the goals, where/how can I reference a segment or custom dimension? I'm not seeing those as an option to select. I see:

Type = Destination, Duration, Pages/Screens per session, or Event
(Screenshot: http://cl.ly/0v2u421Y1p0q )

I assume "Destination" is what I'd want. But then I only have these options to identify the pages:

Destination Equal to, Begins with, or Regular expression
(Screenshot: http://cl.ly/0z0E1v3Y3j0M )

Am I missing something?

Re: Excluding certain URLs with regex

Top Contributor
# 6
Top Contributor
Oops...sorry. Forgot you were using the regex for a goal definition. Yes, the custom dimension idea won't work.

As for using segments, that was also a half-thought-out idea. I was thinking you could create a goal with the all-inclusive expression, then use the segment to exclude the ones (sessions with goals) that you didn't want to see in your reports, but I think it is possible to have both goals in one session, so maybe that's a bad idea as well.

That takes us back to your original problem...and I guess my original thoughts -- is there a different way to express what you want without using an exclusion in the expression? like s-TY|e-TY or other list of partial matches that cause the undesireables to fall out.
Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Re: Excluding certain URLs with regex

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
Hmm not that I can think of at the moment. There hasn't really been a naming scheme for the URLs so I fear I'll end up with a crazy long expression. But that may be my only option after all. :/ Thank you for taking the time to help me out. Time to put my headphones on and think this all through. Smiley Happy Thanks again!