0

The website in question has different parts and functionality. E.g. one part is a blog, another a shop and then there are meta-pages. The site is structured as follows:

example.com/blog                 // Blog main page
example.com/blog/post-name       // Blog posts
example.com/shop                 // Shop main page
example.com/shop/product-name    // Products
example.com/legal                // Meta page
example.com/about                // Meta page

I want to create a segment in Google Analytics of sessions which did not leave the blog. Or in other words: once the user loads a page which does not start with /blog, the session is excluded from the segment.

Therefor I created the following condition for my Blog only segment under *Admin > Segments > Blog only > Conditions.

Segment condition

I read this as "Exclude all sessions from this segment which have a page that starts with anything other than /blog.

However, all sessions are ending up in this segment. What is going wrong here?

1 Answer 1

3

Analytics segmentation conditions offer much more operators, than regex. If there's no specific reason behind choosing regex, you could simply go for the following condition, which matches your described requirement.

Filter >> Sessions >> Exclude
Page >> does not start with >> /blog

In case you prefer to or have to use regex, please find detailed description of regex in Analytics here. Also, I'd suggest to try the following expression, based on this sample:

^((?!\/blog).)*$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.