Specific kind of search analytics

Hi, I want to get a specific kind of information about how my users are searching. When a user clicks Search, I want to know:

  • What page they were on when they clicked Search
  • What search query they typed in the search box

The complicating factor is that clicking Search takes the user to a search page, so I guess my question is whether it’s even possible to get this information (does the HTTP_REFERER get logged). If so, how can I do it? Do I have to use the Get Logs API?

Has anyone ever tried to do this?

Hi @pconrad,

With InstantSearch on the frontend you can access your state data and then push it to the data analytics platform of your choice with the analytics widget.

Below please find a snippet showing how you can first view the data you mentioned, it is then up to you to code the function that pushes to GA/GTM/Segment:

  instantsearch.widgets.analytics({
    pushFunction(formattedParameters, state, results) {
      console.log(state.query);
      console.log(state.page);
    },
  })

How does that meet your needs?

Thanks! Let me see what I can do with this.