![]() |
|
|
|
||||||||||
![]() |
|
|
Thread Tools |
|
#1
|
||||
|
||||
|
Any way of capturing the exit url when someone leaves?
Does anyone know of a method to capture the url someone has clicked on when they are leaving your site? I'd like to know the destination of a visitor if they click on an ad or type in a new address. It would be helpful to know where they are going, moreso than just the url of the page they exited from.
|
|
#2
|
||||
|
||||
|
You could do it with a JavaScript embedded on all your pages that do something based on when the user leaves. A more common way of doing it would be to make all your links clickable to a script that redirects.
__________________
- Shawn Keyword Tracker now supports Google (once again) as well as Bing (new) and Yahoo Please do not PM, IM or email me for product or tool support (they will go unread/ignored), and don't "friend" me unless we are really friends. |
|
#3
|
||||
|
||||
|
I use the redirect on my own web site. For the corporate site I maintain, we don't have many external links, only to our other division's sites. However, I'd like to know if a person goes back to where they came from, types in a new address or clicks on one of our division's sites (don't want to loose the anchor text links for redirection).
So, in javascript, what method would I use on the onExit function, to capture the url and store it in a database? |
|
#4
|
||||
|
||||
|
"types in a new address..."
now you are getting into privacy issues.... who do you think you are...google?
|
|
#5
|
|||
|
|||
|
Quote:
you must have a PHP that does the database job... and then from javascript you take the url of the current page stored in window.location.href into a variable then you pase it to the PHP using an image document.getElementById('imageid').src= 'http://path_to_php?exitURL='+window.location.href; that should do it... from here is a PHP job |
|
#6
|
||||
|
||||
|
window.location.href
window.location.href does not gets its value from the address bar.
see this page: http://www.moshbox.com/testing/windo...tion-href.html change the address bar value and press the first link. . |
|
#7
|
|||
|
|||
... funny guyyou cannot, by any means cannot capture what it's written in the address bar... you can capture that only if you press enter after you type in something new as for the mail topic starter... if you want to track the url they click on right before they live... instead of using window.location.href... use the url in the link they clicked on... this means you have to redirect all the links |
|
#8
|
|||
|
|||
|
Quote:
__________________
Free Directory Script | IndexScript Skins | Check out my latest script - a URL Shortening Script - Last edited by daboss; Jan 19th 2005 at 6:54 am. Reason: typo |
|
#9
|
|||
|
|||
|
A bit late but anyway...
I found this thread while looking for a solution to this problem. Here is what I've come up with so far. No need to screw around with your link tags -- just add the image tag in your document to direct log data to the PHP script (or whatever). Works with Explorer 6 and Firefox, untested with other browsers.
Code:
<html>
<head>
<script>
document.onclick = exitURL; // route all click events
function exitURL(e) {
if (!document.getElementById) return true; // DOM only
var eTag = document.getElementById('tracker');
var uLog = '/path/to/logscript.php?url=';
var isLink = false;
if (!e) {
var e = window.event; // IE
var elmClick = e.srcElement;
} else {
var elmClick = e.target; // FF
}
while (String(elmClick.nodeName) != "A") {
elmClick=elmClick.parentNode; // up the tree
if (String(elmClick.nodeName) == "HTML") return true;
}
url = String(elmClick);
if (url.indexOf("http") != -1 && url.indexOf(location.hostname) == -1) {
eTag.onerror = function() { document.location.href = url; }
eTag.src = uLog + url;
return false; // wait for log, then leave page
}
return true; // pass back to originating object
}
</script>
</head>
<body>
<a href='http://www.example.com'>Example</a>
<img id='tracker' width=0 height=0 border=0>
</body>
</html>
Last edited by greensweater; Nov 29th 2005 at 2:17 pm. |
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Domain Name Exit Fees! | LucidNet | General Chat | 2 | Jun 19th 2004 11:34 am |
| Capturing Search Terms in the Search Tool? | ProductivePC | All Other Tools | 3 | Jun 4th 2004 5:49 pm |