(Correct me if I'm wrong.) A server host can detect the pages that a visitor goes to before and after they visited the host's site.
To what extent can a server host receive information on what sites their client visits before and after th开发者_高级运维e visit to the present page?
There are probably two ways of doing this, which both serve different purposes:
If a user clicks a link on another page to go to your page, the page they came from (the referrer) will be sent in the
Referer
(sic) HTTP header. (See the HTTP specification.)Most web frameworks and web-oriented languages provide an easy way to access this value, and most web analytics tools will process it out of the box. (Specifically how you go about getting at this value depends on what tools you use.) There are three caveats, though:
- This header can be turned off in the settings on most browsers. (Most users don't do this, but a few tech-savvy and privacy-conscious users might.)
- This only works if the user clicks a link. If the user types in the web address manually, the header won't be there.
- You can only see one page immediately before the visit to your site.
If you want to see where a user travels across pages which you control, you can do this by setting a cookie with a unique value per visit, and storing each page load.
Like the above one, how you go about doing this depends on what tools you use, and there are a few caveats:
- Like the
Referer
header, some tech-savvy and privacy-conscious users like to browse with cookies switched off. - Obviously, you can only see visits to pages that you control yourself (and that you can set cookies on).
- Like the
精彩评论