How can I count keywords in a search? | Community
Skip to main content
February 7, 2023
Solved

How can I count keywords in a search?

  • February 7, 2023
  • 3 replies
  • 3006 views

I'm trying to learn more about how customers search on an ecommerce website. It would be useful to know the distribution of multi-token queries - a simple way to do this would be to count the number of spaces that appear in the term.

 

For "air fryer" - that's two words separated by a space, so I'd track that as 2 Keywords. "Nintendo Switch Games" would be 3, and so on.

 

Ideally I'd plot this on a histogram to show the distribution.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by yuhuisg

Try this: use a list prop to track your search term. Reference for list props: https://experienceleague.adobe.com/docs/analytics/implementation/vars/page-vars/prop.html?lang=en#list-props

For example, let's say you have configured prop13 as a List prop and track your search terms to it. Assuming you have configured the list delimiter as " " (i.e. space), then tracking the following:

 

s.prop13 = "Nintendo Switch Games";

 

should result in getting back the values

"Nintendo"

"Switch"

"Games"

when you run a report on prop13 values.

Take note that with this approach, you're still subject to the 100-byte limit of props. So you can't track "Nintendo Switch Games featuring Mario and Luigi and Bowser who are racing through the streets while throwing mushroom bombs" because that exceeds 100 bytes. If you think you need to track long strings, then you'll have to use a "list" variable https://experienceleague.adobe.com/docs/analytics/implementation/vars/page-vars/list.html?lang=en. Note, though, that each report suite can only have a maximum of 3 "list" variables.

3 replies

VaniBhemarasetty
Adobe Employee
Adobe Employee
February 7, 2023

@sosulli use a custom javascript code in Adobe Launch and to count the number of values that user is typing to search and capture in an eVar and report it out in workspace

sosulliAuthor
February 7, 2023

Thanks VaniBhemarasetty - is there a way to do this downstream in the report suite? In terms of how our teams and processes are set up, going with custom JS is going to take a long longer to achieve the same results.

PratheepArunRaj
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
February 7, 2023

Dear @sosulli ,

If it is possible to create a RegEx Pattern for the said requirement, then you can do it using Classification Rule Builder without the tagging effort.

Thank You, Pratheep Arun Raj B (Arun) | NextRow DigitalTerryn Winter Analytics

 

Thank You, Pratheep Arun Raj B (Arun) | Xerago | Terryn Winter Analytics
yuhuisg
Community Advisor
Community Advisor
February 8, 2023

However, with this approach, you'll need to know in advance the number of Classified values that you want, which may be a difficult task considering that users are free to enter as many search words as they want.

For example, if you have 2 Classified values only, then "Nintendo Switch Games" would get classified into "Nintendo" and "Switch" but not "Games".

PratheepArunRaj
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
February 8, 2023

The solution given is not to classify the values, but to count the spaces to understand the number of words. Yes, the numbers have to be manually entered but it is the better option compared to the implementation.

Thank You, Pratheep Arun Raj B (Arun) | Xerago | Terryn Winter Analytics
yuhuisg
Community Advisor
yuhuisgCommunity AdvisorAccepted solution
Community Advisor
February 8, 2023

Try this: use a list prop to track your search term. Reference for list props: https://experienceleague.adobe.com/docs/analytics/implementation/vars/page-vars/prop.html?lang=en#list-props

For example, let's say you have configured prop13 as a List prop and track your search terms to it. Assuming you have configured the list delimiter as " " (i.e. space), then tracking the following:

 

s.prop13 = "Nintendo Switch Games";

 

should result in getting back the values

"Nintendo"

"Switch"

"Games"

when you run a report on prop13 values.

Take note that with this approach, you're still subject to the 100-byte limit of props. So you can't track "Nintendo Switch Games featuring Mario and Luigi and Bowser who are racing through the streets while throwing mushroom bombs" because that exceeds 100 bytes. If you think you need to track long strings, then you'll have to use a "list" variable https://experienceleague.adobe.com/docs/analytics/implementation/vars/page-vars/list.html?lang=en. Note, though, that each report suite can only have a maximum of 3 "list" variables.