HTML5 Search -- Null results detection and custom page

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets

HTML5 Search -- Null results detection and custom page

Postby JRtechw on Sun Aug 11, 2019 7:10 pm

Hi Flare users,

I did search for anything related to null or empty searches in here and couldn't find anything.

So I want to detect a search that returns no results, and:

a) redirect to a custom 'no results' page with info on search refinement and alternate options for better searching
b) send the null search event to Google Analytics so search terms with no results can be tracked and actioned.

Sending the event to GA is pretty easy: detect that no search results have been returned, retrieve the search term used from the query URL component, and fire off the event to GA with a gtag command.

However, there's no way in Flare's default search that I know of that detects that no search results have been returned (short of hacking Flare's search js, and I'd really rather not). The number of search results is inserted at page load time:

>
<h1 id="results-heading"><span class="query"></span> returned <span class="total-results"></span> results.</h1>
<

So I'm not even sure I can detect no results by searching for a text snippet with a bit jQuery.

Has anyone else wanted to do this with Flare's default search, or do most users seeking that level of complexity rely on Pulse or Elasticsearch's dashboards? Given how important catering for null search results is from a design point of view, I'm surprised you can't redirect to a custom master page on a null search.

Thanks.
JRtechw
Propeller Head
 
Posts: 46
Joined: Thu Oct 05, 2017 8:08 pm

Re: HTML5 Search -- Null results detection and custom page

Postby JRtechw on Sun Aug 11, 2019 7:48 pm

Turns out this question *has* been asked before, more or less:

viewtopic.php?f=13&t=27867

I'll use Dave Lee's null result detection code and see how that goes. I can probably just expose a div with said advice on an empty search detection.
JRtechw
Propeller Head
 
Posts: 46
Joined: Thu Oct 05, 2017 8:08 pm

Re: HTML5 Search -- Null results detection and custom page

Postby JRtechw on Mon Aug 12, 2019 8:34 pm

Success!

If you use gtag.js and not analytics.js, the event to send would be something like:

Code: Select all
gtag('event', 'No results', {
'event_category': 'search',
'event_label': searchTerm,
});


where <searchTerm> is the search term that produced no results, captured by your null result capture javascript. Then, in Google Analytics, go to Behaviour > Events > Top Events and set your primary dimension to 'Event Action' and your secondary dimension to Event Label and there's your Nil Result Search Report.
JRtechw
Propeller Head
 
Posts: 46
Joined: Thu Oct 05, 2017 8:08 pm

Re: HTML5 Search -- Null results detection and custom page

Postby Dave Lee on Tue Aug 13, 2019 12:20 am

Yep, I posted that solution in July 2017, using the original analytics ga() code. But Google replaced that in Aug 2017 by the new gtag() code.
Dave Lee
Master Propellus Maximus
 
Posts: 5675
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: HTML5 Search -- Null results detection and custom page

Postby JRtechw on Sun Aug 18, 2019 9:53 pm

Much appreciated on that null result detection code btw Dave. I was scratching my head wondering how I'd grab the number of search results.
JRtechw
Propeller Head
 
Posts: 46
Joined: Thu Oct 05, 2017 8:08 pm

Re: HTML5 Search -- Null results detection and custom page

Postby bunnycat on Tue Dec 10, 2019 5:40 am

This thread has been very helpful for me with integrating Google Analytics. I'm sort of surprised GA doesn't have this out of the box as a result.
I saw immediate results when I implemented Dave Lee's code snippets for null search results (THANK YOU!).
This will help us craft up some solutions in Flare (synonym usage, keywords, search usage tips, etc) for failed searches.

I still wonder how we can assist when a search HAS results but the user doesn't click through to any topics. I saw those as Site Content hits - because it recorded the page URL of the Search query - however those hits don't show up in Site Search module in GA because user didn't click through to a topic and just sat on the results page. Interesting...
In GA, my site is set for Site Search for term,search,query,Highlight, so I suspect it should be gathering "all" the information?!? The GA help isn't very helpful about exactly "what" that will collect and how it'll be presented.

Anyway, adding this null results detection helps narrow up a gap in our analytics. So that's all good!

-CAT
bunnycat
Propeller Head
 
Posts: 60
Joined: Tue Nov 03, 2015 6:44 am

Re: HTML5 Search -- Null results detection and custom page

Postby Dave Lee on Tue Dec 10, 2019 6:34 am

bunnycat wrote:In GA, my site is set for Site Search for term,search,query,Highlight, so I suspect it should be gathering "all" the information?!?


When do you use term,search, and query?

I was only aware of "Highlight" and "q" being used as Query parameters in Site Search.

For example:
* On the search results page, it'll collect the search term for the "q" parameter; e.g. q=term
* If you click a topic, it'll collect the search term for the "Highlight" parameter; e.g. Highlight=term

But if you enter muliple parameters like "Highlight" and "q", whilst you will record all the data, aren't you also counting each search twice?
Dave Lee
Master Propellus Maximus
 
Posts: 5675
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: HTML5 Search -- Null results detection and custom page

Postby bunnycat on Tue Dec 10, 2019 6:53 am

Dave Lee wrote:
bunnycat wrote:In GA, my site is set for Site Search for term,search,query,Highlight, so I suspect it should be gathering "all" the information?!?


When do you use term,search, and query?

I was only aware of "Highlight" and "q" being used as Query parameters in Site Search.

For example:
* On the search results page, it'll collect the search term for the "q" parameter; e.g. q=term
* If you click a topic, it'll collect the search term for the "Highlight" parameter; e.g. Highlight=term

But if you enter muliple parameters like "Highlight" and "q", whilst you will record all the data, aren't you also counting each search twice?


I'm not really certain - as the GA site settings were set up previously this way. I suspect it may have been a remnant query parameter from some very old custom tracking code back when it was under the older ga code?!? (I'm unsure) I experimented a little with the query parameters this morning, juggling around the query and Highlight, and attempting to use just the q abbreviated form. The q parameter seems to work to gather a search result when use sits on the results page without clicking through.

Thank you Dave for the extra insight and questions. It made me consider why my site analytics were set up strangely/extra. I don't think the term,search parameters do much at all.
-CAT
bunnycat
Propeller Head
 
Posts: 60
Joined: Tue Nov 03, 2015 6:44 am


Return to Web-based Outputs

Who is online

Users browsing this forum: No registered users and 4 guests