Reputation: 3
So I would like to only view certain pages in one explorer in google analytics how do i do so?
For example:
example.com/contact < (exact match and not anything beyond contact/example)
example.com/blog
example.com/how-to
I tried using segments with the conditions "exact matches" but what happen is that it still shows me all the pages that is not relevant to the above conditions when I view the segment on my behavior> site content> all pages.
And advance filtering limits to just "AND" even I tried using "matching regexp" with "/(contact|blog|how-to)" It still show everything after "/contact/example/example"
Any idea how to solve this issue?
Upvotes: 0
Views: 88
Reputation: 52
Not that the end result in this particular case would yield anything different but I just think it is best practice escaping slashes also in regexes in Google Analytics too just in case the regex is copied and used somewhere else like Perl e.g.
Here is a shorter version:
^\/(contact|blog|how-to)$
Upvotes: 0
Reputation: 884
You need to learn about Analytics Regular Expressions (or Regex).
'$' means 'ends here' '^' means 'begins here' '|' means 'or'
So ^/page1$ will search for exactly that page, and ^/page1$|^/page2$ will search for one of the two pages.
Now Google Analytics will cut out the hostname, so you'll want to search or filter for: ^/contact$|^/blog$|^/how-to$
There are many more of these ('.' means 'any character', for example) and you can find guides online such as this one https://support.google.com/analytics/answer/1034324?hl=en
Upvotes: 0
Reputation: 32760
Try to conclude your regex with $ (/how-to$), meaning "ends with the preceding character. GA regex is a bit overeager and assumes you want to match anything that contains your string, so you have to specifically terminate with the ends-with metacharacter.
Upvotes: 1