AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4.8K members online now
4.8K members online now
Ask questions about filter set-up and issues with using filters in Google Analytics reports
 
Guide Me
star_border
Reply

Regex Help - Segments

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi

 

This query has to do with segments rather than filters.

 

I am trying to isolate data for a group of pages using a segment and creating a Regex OR formula. I want the segment to contain a group of 50 pages. However, my Regex (shown below) only seems to return the first page.

 

^/b2b-sales-funnel-look-like-can-convert-leads-opportunities-faster.*|^/lead-generation-targets-financial-goals.*|^/data-backed-buyer-persona-development.*|^/inbound-marketing-content-strategy.*|^/planning-inbound-marketing-campaign.*|^/hubspot-blog-migration.*|^/4-workflow-automation-tips-help-busy-b2b-marketers-convert-leads.*|^/buyer-personas-shorten-software-sales-cycle.*|^/buyers-journey-content-reduce-software-sales-cycle.*|^/youtube-advertising-how-trueview-helps-inbound-marketing-campaigns.*|^/what-is-inbound-sales.*|^/linkedin-account-targeting.*|^/inbound-marketing-campaign-checklist.*|^/inbound-campaign-content-hubs.*|^/inbound-marketing-channel-promotion.*|^/inbound-marketing-podcast.*|^/mapping-content-buying-cycle.*|^/paid-advertising-inbound-marketing.*|^/gated-content-best-practices.*|^/lead-nurturing-inbound-marketing.*|^/how-often-should-a-business-blog.*|^/should-i-have-competitor-connections-linkedin.*|^/content-marketing-channel-strategy.*|^/inbound-marketing-campaigns.*|^/infographic-inbound-marketing-mistakes.*|^/inbound-marketing-glossary.*|^/inbound-sales-b2b-companies.*|^/inbound-sales-methodology.*|^/inbound-marketing-business-goals.*|^/inbound-marketing-campaign-optimisation.*|^/marketing-budget-by-channel.*|^/account-based-marketing-tactics.*|^/lead-nurturing-email-best-practices.*|^/inbound-marketing-social-media-strategy.*|^/inbound-sales-tips.*|^/inbound-marketing-cro.*|^/why-use-linkedin-sponsored-inmail.*|^/inbound-marketing-questions-answered.*|^/best-time-inbound-sales-conversation.*|^/linkedin-prospecting-best-practices.*|^/what-can-learn-hubspot-training-courses.*|^/effective-content-marketing-formats.*|^/b2b-blog-post-best-practices.*|^/how-conduct-first-inbound-sales-call.*|^/inbound-sales-barriers.*|^/inbound-marketing-vs-outbound.*|^/lead-data-sales-reps-first-call.*|^/lead-nurturing-tactics.*|^/how-resource-inbound-content.*|^/what-is-a-compounding-blog-post.*

 

Sorry to just paste the whole thing but thought it might help :-)

 

When I save this segment GA only returns data for the first page ie /b2b-sales-funnel-look-like-can-convert-leads-opportunities-faster

 

Does anybody know where I might be going wrong?

 

Many Thanks

 

Anna

1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Anna G
June 2016

Re: Regex Help - Segments

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆
The problem is that in every page that you include in your regex you use "^". For example:

^/b2b-sales-funnel-look-like-can-convert-leads-opportunities-faster.*|^/lead-generation-targets-financial-goals.*|^/data-backed-buyer-persona-development.*

To make it work remove "^" sign from everywhere except for the first expression and escape (use "\") every slash character in your expression. Using above example:

^\/b2b-sales-funnel-look-like-can-convert-leads-opportunities-faster.*|\/lead-generation-targets-financial-goals.*|\/data-backed-buyer-persona-development.*

To make sure that your expression works as expected I would highly recommend using regexr.com. It's simple yet powerful.

Please let me know if it worked for you - I tried it the way I provided in the example and it seems that it matches all your pages.

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Anna G
June 2016

Re: Regex Help - Segments

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆
The problem is that in every page that you include in your regex you use "^". For example:

^/b2b-sales-funnel-look-like-can-convert-leads-opportunities-faster.*|^/lead-generation-targets-financial-goals.*|^/data-backed-buyer-persona-development.*

To make it work remove "^" sign from everywhere except for the first expression and escape (use "\") every slash character in your expression. Using above example:

^\/b2b-sales-funnel-look-like-can-convert-leads-opportunities-faster.*|\/lead-generation-targets-financial-goals.*|\/data-backed-buyer-persona-development.*

To make sure that your expression works as expected I would highly recommend using regexr.com. It's simple yet powerful.

Please let me know if it worked for you - I tried it the way I provided in the example and it seems that it matches all your pages.

Re: Regex Help - Segments

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Andrzej

Thanks very much for providing a solution. It worked perfectly!

I understand where I went wrong with not escaping the forward slashes, but I thought a ^ means that this is the beginning of the url. So that is why I put them in.

Why does the ^ only go before the first uri and not the others?

Thanks again for your help :-)

Anna

Re: Regex Help - Segments

Explorer ✭ ✭ ☆
# 4
Explorer ✭ ✭ ☆
Glad I could help Smiley Happy.

As for your question - "^" literally means "there can't be any other character before me" Smiley Happy. So when you add second "^" in your regular expression then above rule is automatically violated and expression doesn't check anything after this point. It's because before second "^" you have some part of your regular expression. So expression will only work for the part before second "^".