I suppose you’ll only know that the user has finished searching when they choose one of the results, so the logical solution is to send an ajax request to a search logging action when the user picks a result and before they’re redirected to the relevant page. You could capture the search term and the result that the user chose, which might be useful in the future for prioritising search results.
True, but when they don’t click or any results are found, I can’t log is. What I want to do, is make it more sophisticated later and use this data for suggesting search terms when the user is making a typo etc.
I’ve been thinking to delete a previous log record of a user when within 0.5 seconds or so.
But I think the best solution is to make a timeout on the jquery side.
I was just curious if anyone have dealt with this before and maybe got a good tip for me. If so, please let me know.