Reputation: 2253
I have a problem with an advanced filter, that is supposed to recognize filtering and searching and create a proper Search category.
Urls for filtering: example.com/search/category:searchTerm
Urls for searching: example.com/search/searchTerm
Filter:
/search/(.*):(.*)$
Output to -> Constructor: Filter: $A1
This works fine. I see Filter:Category in the analytics report's Site search Category.
Now, I would like to separate search terms without ':' which means, the user put the term into the search field and didn't use the filter. Anything without ':' should be the Search category.
/search/((?!:).)*$
Output to -> Constructor: Search
This doesn't work, the Site search Category is not set to Search. Any idea where the error is? Is it even possible to have multiple filters for the same output?
Upvotes: 0
Views: 334
Reputation: 1633
If you check the Google Analytics support page about regular expression, you won't find the negative lookahead syntax. So it is not explicitly stated, but most likely you are trying to use a syntax, that is not supported in Google Analytics. If you use this same regular expression in any your Behavior > Content > All pages report as a filter, you will also get a syntax error:
So this should be the reason for your error. Regarding possible solutions, you might want to go for a specific string type, without the colon:
\/search\/([\w-%]*)[\?|$]
Please note, I have escaped the slashes, and also allowed (but not included) any parameters to be present in the string. Working example: https://regex101.com/r/viTcb1/2
Upvotes: 1