Is It Possible To Track Visitor That Leave Or Page To Another Sites?
Is it possible to track visitor that leave or page to another sites, like ask question only when they want move to another sites or other domain name? I write this code
<script language="JavaScript">
$(document).ready(function(){
$("a").click(function(){
if( fnGetDomain(document.location) == fnGetDomain($(this).attr("href")) )
{
return true;
}
else{
return confirm("Leave page?");
}
});
});
function fnGetDomain(url) {
return url.match(/:\/\/(.[^/]+)/)[1];
}
</script>
You can use document.location.href
in place of document.location
if there is any problem
Solution 3:
I've tried a thing here, not sure it works on every cases...
window.onbeforeunload = confirmExit;
function confirmExit(event)
{
console.log(event);
console.log("Current : " + event.srcElement.domain);
console.log("Target : " + event.target.domain);
if (event.srcElement.domain != event.target.domain)
{
return "leave ?";
}
else
{
// staying here
}
}
Post a Comment for "Is It Possible To Track Visitor That Leave Or Page To Another Sites?"