I have a dimension that gives me search queries, most of which are one word ... but I want to find all those that are 2 or more words.
I used segment builder to create a filtering on "contains" for " " and ' '.
The end result is the system delivers only queries that contain either ' or " - interesting that this exists but absolutely not what I wanted.
Any ideas????
Solved! Go to Solution.
Views
Replies
Total Likes
Lol, so it does... I swear it used to trim whitespace and not accept a space on its own.. I figured that was why they were trying to use " ".
Yeah, no need to use classifications then... unless you need to get groups by number of words (1 word, 2 words, 3 words,.... 5+ words)
Lol, yeah, unfortunately, the segment builder is looking at the literal " or ' text... there is no "advanced" way of searching for an actual space... at least not here.
You could create a classification on your Search Query dimension though, and use regex to identify if there are spaces.
So I did a quick test, using regextester.com:
You can also check for "no space":
This will match if there is any space... So if it matches, this should mean there is more than one word (unless the search query was " something" or "something " and the space wasn't trimmed from the from or end of the query)
So, in your Classification, I would first put in a catchall (or specifically use the no space regex), that sets the "has multiple words" (whatever you call it) to "no" or "false" or "single word" however you want to indicate that, then check for space, and set the classification to the opposite ("yes" or "true" or "multiple words").
If you need to get fancy and look for the number of words, I don't think you can get a count out directly, but you could get fancy and look specifically for one space, two spaces, three spaces, etc... then have a "5 or more" rule at the end.
However you end up setting it up, know that Classifications process every 4-6 hours, so you can't use it on "today's data" too reliably... but your classification rule can process up to 6 months of data in the past, so you should be able to have a history available to you once the initial processing is complete.
Now, when you create your segment, instead of using your Search Query dimension directly, you can use your new classification, and look for "yes" or "true" or "multiple words", or whatever value you set when there is a space.
Views
Replies
Total Likes
Now, depending on your needs, a classification may be a lot of work...
You could also just use the filter option on your table to search for space?
(There is a space there, you just can't see it)
It works for me on my Search Keywords dimension.
However, if this needs to be combined with other uses, like "percent of searches with multiple words" or something else that requires the use of a segment, then the classification thing is probably your only option (short of adding a new JS solution in Launch to evaluate the number of words in the search and pass that as a new dimension)...
Views
Replies
Total Likes
Is there a reason you didn't just put a space in the segment builder without the quotes? Using a space in the segment builder does work.
Just do what you were doing, except get rid of the quotes, just put a space.
Lol, so it does... I swear it used to trim whitespace and not accept a space on its own.. I figured that was why they were trying to use " ".
Yeah, no need to use classifications then... unless you need to get groups by number of words (1 word, 2 words, 3 words,.... 5+ words)
Thanks - as you said - it used to trim spaces but now it doesn't - great
Amazing! Thanks for the tip.
I want to create a segment called 3 or more words in search query.
As the name implies it would only capture the keywords where there are 3 or more words in the search query.
How can I do that?
Views
Replies
Total Likes
If you want to do it based on the number of words in the query, you would need to do a classification. The method that @Jennifer_Dungan described above, using regex in a classification to essentially count the number of blank spaces. Have a resulting classification field with a value like "one word", "two words", "three words" etc. Then you could bring in that field into your table to look at just search terms with x amount of words. If you want to look at "three or more words" for example, you would need to build a segment with the different values, like "three words", "four words", etc.
Thank you! I will move into the classifications builder then
FYI, I don't know if you can do a specific regex by count, since the {#} qualifier looks for the aforementioned items all in a row (so /(\s){3}/g would need to have " " but would not catch "test test test test"), but you can use rules like:
/\s/g - at least one space
/\s.*\s/g - at least two spaces
/\s.*\s.*\s/g - at least three spaces
etc.
If you do the classifications in the correct order, checking for no space (set that as "one word"), then check for one space (set as "two words"), check for two spaces (set as "three words"), etc
(This might still fail based on words if someone actually searched by "test test" [three spaces in the middle]... but should work for most cases...
The final rule (where ever you stop), would end up being set to "X+ words"
If you can find better regex, I would love to see them...
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies