How does the web site learn the query that led some user to his site via a search engine?

Just now I realized that I didn’t know how this worked. I think I do now. When I asks a search engine to find references to “rumplestilskin” my browser sends an http message with the request including “rumplestilskin”. The search engine responds with a page and an URL according to the http protocol. This is the URL usually displayed by my browser in the address bar. Embedded in that URL is “rumplestilskin”. When the standard browser follows a link in includes in the http message (as the referrer value) the URL of the page containing the link. In this case that value contains “rumplestilskin”. The web server software records this information associated with the IP address, time and page recommended by the engine.

A modified browser may choose to omit this information.