Once upon a time you could get this information from the HTTP_REFERER header, since search terms were essentially encoded in the query string portion of the URL the search results showed up on.
Not sure how that holds up these days.
Not sure how that holds up these days.