Gravatar for ethan.xu@agencyq.com

Question by ethanx, Aug 27, 2018 5:36 PM

Search submit is tracked as Search Query Link in sitecore

Hi, I am using a global search header box for every page, and recently I found out that all the searches submitted from this box are tracked as Search Query Link instead of Search Query Submit. The problem is that I want to know where searches are being submitted and Search Query Link events are all being registered under the Search page no matter which pages the queries are actually submitted.

I tried to debug the javascript and found this in the SearchInterface.ts, it seems all the submit event is changed to link query on purpose:

if (uaCausedBy != null) {
  // for legacy reason, searchbox submit were always logged a search from link in an external search box.
  // transform them if that's what we hit.
  if (uaCausedBy == analyticsActionCauseList.searchboxSubmit.name) {
    uaCausedBy = analyticsActionCauseList.searchFromLink.name;
  }
  stateValues['firstQueryCause'] = uaCausedBy;
}

The event name doesn't really matter in my case, but the original page on which the search is submitted is useful information, can you help me on how to track this info using the Coveo search box rendering?

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Aug 27, 2018 5:45 PM

When already on the search page, is the page reloaded completely when you do search for new terms? Or is the page content simply updated with the new results?

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Aug 27, 2018 5:59 PM

The way you setup your global searchbox is the cause of your analytics issue. The Global Searchbox component should be inserted inside an "External Components Section" component. The data source item on this component allows you to define a "Coveo search interface data source item". It uses this data source item to detect whether it is on the search page or not. When on the search page, it initializes its child components differently and the global searchbox get bound to the search interface as an external component.

It is very confusing for users when there are 2 searchboxes on a single page. I recommend you only keep the global searchbox.

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Aug 27, 2018 6:19 PM

This response is right and I want to add some details about the underlying behavior:

The key to understanding this issue is how the "Search Query Link" is different from a "Search Query Submit".

A Submit is triggered when the users click on the "submit" button of the Search Interface.

A Link is triggered when the Searchbox is configured as a Global Searchbox and redirects to a Search Interface. You can see that it is redirected by inspecting the URL, it should contain keys like `firstQueryCause` and `firstQueryMeta`. This is how the Search Interface detects that the query comes from a link, hence the `Search Query Link` name.

Thus, by putting the `External Components Section` around the Searchbox, the component is instead directly bound to the Search Interface. So the query executed will be "submitted" like a standard Searchbox instead of trying to redirect like a Global Searchbox.

Gravatar for ethan.xu@agencyq.com

Comment by ethanx, Aug 27, 2018 7:58 PM

Is there an equivalent in the legacy components?

Ask a question