Expand my Community achievements bar.

SOLVED

Internal Search Term tracking

Avatar

Level 3

I'm trying to track internal search terms entered in the search box by visitors on a web page. But the given search box is divided into 3 sub boxes with each search box having its own URL parameter. URL for a sample search appears as (www.example.com/search?k=analyst&c=alliedhealthsocialservices&l=Columbus,%20Ohio&t=regularparttime). How to track all the search terms entered in 3 search boxes? Do i need to create separate Data Elements for each individual search box? Can anyone tell me how do i processed further?

1 Accepted Solution

Avatar

Correct answer by
Level 9

Okay well if those query parameters really do represent arbitrary text a visitor enters into fields, then personally I would push them to separate Adobe Analytics variables instead of concatenate them, because there's no guarantee on how many characters they will be or what characters will be entered.

I'm not sure I understand what you mean... is your site just using different query parameters for search terms, depending on the page or search widget used? So e.g. maybe you do a search and it pops k=[search term] but on search results page you do another search and it instead pops query=[new search term] ?  If so, then it sounds to me like you shouldn't concat them, but instead just look for either one and push to the variable. 

Or is it that a visitor can go to your site and search for something that results in both of those parameters showing up in the URL at the same time, with different values?

I think I need clarification about how your site actually works vs. these two parameters.

View solution in original post

7 Replies

Avatar

Level 2

Hi Srikanth,

I would suggest capturing all the 3 parameter values in respective variables in the custom code of your DTM rule using the getQueryParam utility assuming you are using Appmeasurement library. Your custom code should look something like below:

capture.png

Hope this helps you.

Regards,

Muralidharan

Avatar

Level 10

What is your end goal here? Are you trying to capture each of the search terms in their own variable? If so, the above solution should work. If not, can you give us an idea of what your ideal solution would look like? For example:

I'd like www.example.com/search?k=analyst&c=alliedhealthsocialservices&l=Columbus,%20Ohio&t=regul arparttime to send in an Analytics hit with prop2=Columbus, prop3=Ohio, eVar4= regul, ect...

Or

I'd like www.example.com/search?k=analyst&c=alliedhealthsocialservices&l=Columbus,%20Ohio&t=regul arparttime to send in an Analytics hit with prop2=Columbus-Ohio, eVar4= regul, ect...

Avatar

Level 9

As others have stated, can you please clarify / provide more details about which query parameters represent what?

Based on what you've said vs. what I see in the URL, it seems like k=, c=, and l=  are pre-defined dropdown/selection/filter values, and t= is the actual search term?  If so, I would consider keeping the t= (actual search term) as a separate eVar, and depending on char lengths for the other ones, I would push them all to a single eVar concatonated, e.g. "[k=]|[c=]|[l=]"  and then create classifications and classification rules to break them out into classified reports.

Avatar

Level 3

Hey Josh,

Thanks for helping me, K and l are actual search terms. C is a drop down selection value.  Other than that I have one more question

what if my URL parameter dynamically changes from k=xxxx to query=xxxx when the page loads? Can i concatenate both k and query into a variable as "[K=][query=]" and capture search terms?

Avatar

Correct answer by
Level 9

Okay well if those query parameters really do represent arbitrary text a visitor enters into fields, then personally I would push them to separate Adobe Analytics variables instead of concatenate them, because there's no guarantee on how many characters they will be or what characters will be entered.

I'm not sure I understand what you mean... is your site just using different query parameters for search terms, depending on the page or search widget used? So e.g. maybe you do a search and it pops k=[search term] but on search results page you do another search and it instead pops query=[new search term] ?  If so, then it sounds to me like you shouldn't concat them, but instead just look for either one and push to the variable. 

Or is it that a visitor can go to your site and search for something that results in both of those parameters showing up in the URL at the same time, with different values?

I think I need clarification about how your site actually works vs. these two parameters.

Avatar

Level 3

Hey Josh, Here is the clarification you have asked for. When a user enters a search term in text box and clicks on search button url will be like example.com?k=xxxxx and then after two seconds it changes to example.com?query=xxxxx and the user is directed to search page.

Avatar

Level 9

Okay well, not sure why your site does that.. seems like that's something that should ideally not happen.  But in that case, I would ignore k= param and just look for query= param for search term.