When a page is loaded, the tracking in place provides us with data. This is what we call a hit.
Within this hit, we can find the referrer. It corresponds to the previous page, before the one loaded.
Thanks to this we are able to tell which search engine was used before getting on the tracked page.