Digital Point Forums
Send Telegram

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Jun 16th 2004, 9:47 am
mopacfan's Avatar
mopacfan mopacfan is offline
Starcaller
 
Join Date: May 2004
Location: Mizzery
Posts: 3,266
mopacfan is a name known to allmopacfan is a name known to allmopacfan is a name known to allmopacfan is a name known to allmopacfan is a name known to allmopacfan is a name known to all
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.
__________________
Police Lights - Amber Warning Lights - -
Reply With Quote
  #2  
Old Jun 16th 2004, 9:50 am
digitalpoint's Avatar
digitalpoint digitalpoint is offline
My cat is on Prozac... really. lol
 
Join Date: Mar 2004
Location: San Diego, California
Posts: 22,363
digitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond repute
Phone Verified
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.
Reply With Quote
  #3  
Old Jun 16th 2004, 11:19 am
mopacfan's Avatar
mopacfan mopacfan is offline
Starcaller
 
Join Date: May 2004
Location: Mizzery
Posts: 3,266
mopacfan is a name known to allmopacfan is a name known to allmopacfan is a name known to allmopacfan is a name known to allmopacfan is a name known to allmopacfan is a name known to all
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?
__________________
Police Lights - Amber Warning Lights - -
Reply With Quote
  #4  
Old Jan 15th 2005, 5:54 pm
relaxzoolander's Avatar
relaxzoolander relaxzoolander is offline
Champion of the Naaru
 
Join Date: Apr 2004
Location: columbus, ohio
Posts: 141
relaxzoolander is on a distinguished road
"types in a new address..."
now you are getting into privacy issues....
who do you think you are...google?
Reply With Quote
  #5  
Old Jan 18th 2005, 1:23 am
phrozen_ra phrozen_ra is offline
Champion of the Naaru
 
Join Date: Jan 2005
Posts: 147
phrozen_ra is an unknown quantity at this point
Quote:
Originally Posted by mopacfan
So, in javascript, what method would I use on the onExit function, to capture the url and store it in a database?

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
__________________
Funny Quotations | Reading Glasses |
Reply With Quote
  #6  
Old Jan 18th 2005, 9:06 pm
relaxzoolander's Avatar
relaxzoolander relaxzoolander is offline
Champion of the Naaru
 
Join Date: Apr 2004
Location: columbus, ohio
Posts: 141
relaxzoolander is on a distinguished road
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.
.
Reply With Quote
  #7  
Old Jan 19th 2005, 1:33 am
phrozen_ra phrozen_ra is offline
Champion of the Naaru
 
Join Date: Jan 2005
Posts: 147
phrozen_ra is an unknown quantity at this point
... funny guy
you 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
__________________
Funny Quotations | Reading Glasses |
Reply With Quote
  #8  
Old Jan 19th 2005, 6:54 am
daboss daboss is offline
of the Nightfall
 
Join Date: Oct 2004
Posts: 2,237
daboss is a splendid one to beholddaboss is a splendid one to beholddaboss is a splendid one to beholddaboss is a splendid one to beholddaboss is a splendid one to beholddaboss is a splendid one to beholddaboss is a splendid one to behold
Quote:
Originally Posted by phrozen_ra
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
or you can also use a form with a get action that calls an external php file?
__________________
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
Reply With Quote
  #9  
Old Nov 29th 2005, 1:05 pm
greensweater greensweater is offline
Peon
 
Join Date: Nov 2005
Posts: 1
greensweater is on a distinguished road
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>
All click events are routed through this function, which checks to make sure it's an anchor tag. The indexOf checks for http (non-local) links on different hostnames. The onerror event fires when the image fails to load (because it's not really an image), which then directs the browser to the requested page. Should fail cleanly on browsers that don't support it.

Last edited by greensweater; Nov 29th 2005 at 2:17 pm.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


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


All times are GMT -8. The time now is 7:14 pm.