Building a segment to find multi-word search queries | Community
Skip to main content
January 15, 2025
Solved

Building a segment to find multi-word search queries

  • January 15, 2025
  • 2 replies
  • 1446 views

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????

Best answer by Jennifer_Dungan

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)

2 replies

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 15, 2025

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.

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 15, 2025

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)... 

MandyGeorge
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 15, 2025

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.

 

 

January 17, 2025

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?

VaishuNP
Level 2
February 4, 2025

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... 


Hi Jennifer,

 

I have a quick query: Is it possible to classify the Keyword (AMO ID) variable populated from the Google AdWords integration?