I am trying to use the code provided here: Make a ping to a url without redirecting. The OP has asked to ping a url without opening multiple windows. I would like to do this, but I want to actually visit a second url so I can track the outbound clicks in my server analytics.
Here's the code I'm trying to make work:
<a href="javascript:;" onclick="visitPageX()">link</a>
function visitPageX() {
// send Ajax request to the track URL
setTimeout(function() {
location.href = 'http://{pageXURL}';
}, 300);
}
However, I don't understand where I should be putting my "tracking url". Here's my attempt at it:
<a href="javascript:;" onclick="visitPageX()"><a href="http://externalsite.com/">anchor text</a></a>
function visitPageX() {
// send Ajax request to the track URL
setTimeout(function() {
location.href = 'http://externalsite.com/';
}, 300);
}
I'm stuck at where to put
http://examplemysite.com/tracking.php?123
so that I can count the outbound clicks. I would appreciate it if you could help me get this code working or provide an even better solution to tracking outbound clicks without using Google Analytics.
Your support is very much appreciated.