The standard way to add Sooqr Search to provide data to Google Analytics is to send the search query after a click at a result. You might also want to track the queries your visitor types and doesn't click. It can be done by firing an event. 

Sooqr Search uses a custom tracker that sends statistics to our MySooqr backend. The tracker triggers after 1 second of inactivity (this timeout is hardcoded). So when the user types in characters and stops for at least 1 second, we track it as a search query. If the user adds to the query, another query is tracked.

You can hook into this system by providing Sooqr Search with an event handler inside the Sooqr snippet.

The exact tracking call inside the event handler depends on the Google Analytics tracking version you use. Or possibly even a different tracking solution, separate from Google. Your analytics agency should be able to help you with the correct call.


For reference, this is the event handler that we use. Please note the available parameters:

Query: Search query

Result Count: Total number of results

queryId: Unique query ID, changes when a user starts a new search query (not adds to it)

queryIndex: Each time a user adds to the query, the index is incremented. 


_wssq.push(['suggest._bindEvent', 'trackQuery', function(event, query, resultCount, queryId, queryIndex)
{
   /* Custom Google Analytics tracking */
   if ( 'undefined' != typeof ga)
   {
       ga( 'send', 'event', '/sooqrSearch/?s=' + encodeURI(this.getQueryText()));
   }
}]);

These lines should be added before the 'http/https'-part of the snippet.