The body unload occur before leaving any page. So it won't do the job. But is there any way to capture where the user is headed? So when the address is on another domain something is alerted by this event.
Dears, I don't want to use this as a "please, stay on my site". I want to ask those user that go to order page but anyhow can't submit and finalize the order, and leaving our site to contact us on the phone. So please don't judge it.
preguntado el 27 de agosto de 11 a las 22:08
Esta pregunta is very similar, and like others I would encourage you not to do this for privacy reasons. Knowing when users leave your site is going to be near impossible; if instead you want to track when people use links on your site to dejar your site, you can impliment click tracking via various means: Piwik is one, you can also use some PHP libraries if you have the option.
Usted no puedo however check what URL a user has entered into the search bar; that would be a huge privacy invasion.
If a user types in the URL into his browser, you have no way of knowing what was requested. If he clicks an external link, you again have no way of detecting AFAIK.
However, you can create a redirect page on your server and rewrite all links on the page to point to that page, for instance
www.ExternalSite.com se cambia a
http://www.example.com/redirect.php?u=www.ExternalSite.com. This is how Facebook used to do it.