Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

Tracking Outbound Links with URL Redirecting



12:37 pm on Oct 28, 2009 (gmt 0)

5+ Year Member

Hi Guys,

I thought I would post this here becuase I have checked the net, Google Search, WM Tools Etc and found no real answers.

What I am trying to achieve is as folows:

A client has banner adverts on a website and because at leat 40% of users of this particular website are disabled they ahve javascript turned off (read on see below for why).

The client has asked if we can make these links trackable and record click off stats in the mySQL database.

The method we need to use is as follows:

The link looks like this:

<a href="http://www.example.com" id="1234" onmousedown="javascript:urlout('/out.jsp?url=http://www.example.com');">Click here</a>

Step 1: The user clicks that link.
Step 2: The javascript changes the "this.href" value to '/out.jsp?url=http://www.example.com' and then the link activates sending them to the "out" page.
Step 3: The 'out' page records the url the user is going to and then displays a HTML message to the customer telling them where they are going.
Step 4: Javascript 'redirect' function on the 'out' page activates sending them to a 'GO' page:


The 'GO' page uses a 301 redirect to send the user to the final destination.
Step 5: the user lands at the final destination.

Why so many steps and why not just put that URL in the href in the first place?

Like Google.com, we have to account for any users that do not have javascript installed. Anyone sho does not have javascript installed will fall short at step 3 and they will get stuck there.

Why have step 3 at all?

The website owner has been very specific that he wants to be very clear about the fact that this is an advert and to not confuse the user, he wants to be clear.

This website sells things and gives information for phisically and mentally disabled. They might have javascript off for some disability reason or just because they have a mental illness and they obsessively have it switched off.

The fact is that the website owner is worried that this type of redirect may cause his site to be treated as an affiliate site and not it's true purpose by the search engines.

He is pretty savvy as am I when it comes to SEO, but this redirect and record system, and indeeed how to do it right, is a grey area.

So the main questions are as follows:

In step 2, if javascript is turned on, the url is replaced from the original to the redirect url ONCLICK. Exactly as Google does it. Will this be penalised?

In step 3, if javascript is turned on (which it should be, or we would have never got there in the first place right), it redirects to the 'GO' page which has a 301 redirect to the destination page. Will this be penalised?

Anyone any comments on if we are doing anything ethically wrong here?


12:56 pm on Oct 28, 2009 (gmt 0)

5+ Year Member

Needless to say if javascript is switched off then the url remains to be:

<a href="http://www.example.com" id="1234" onmousedown="javascript:urlout('/out.jsp?url=http://www.example.com');">Click here</a>

But might aswell not have the javascript:
<a href="http://www.example.com" id="1234">Click here</a>

I considered writing something into the code to remove the "javscript" but, again that would be seen as showing different content to different users and I believe Google and other SEs penalise that too?


2:01 am on Oct 29, 2009 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to WebmasterWorld iceomnia :)

I can't see too many problems with your current setup. The straight link to the site with the

a href=""
will be used by bots (such as Googlebot), and the Javascript link will be used only by "real" users who have JS enabled. This means that your click-through stats are more accurate.

A couple of things - firstly, you should exclude /out.jsp in robots.txt (advanced bots seek out URLs in JS snippets, you want them to only follow the href URL and not your click-tracker). Secondly, your "step 3" mentions an interstital page, is this necessary? Can't you simply count the click and issue the 301 instead of having a separate "Go" page?

You should also avoid using

- I simply use the following on a directory site:

<a href="http://example.com/" onclick="window.location.href='/rd.php?id=123';return false;">link text</a>

Our dedicated Javascript forum [webmasterworld.com] may be able to come up with an unobtrusive way of having a click-tracker without an onclick/onmousedown attribute for each link.


10:30 am on Oct 29, 2009 (gmt 0)

5+ Year Member


I have asked a related question here:

http://www.webmasterworld.com/javascript/4015501.htm [webmasterworld.com]

So I have written the following into the client's robot.txt to reflect the following:

Disallow: /out.jsp

is this correct becuase 'out.jsp' will always have an additional parameter?

Secondly, your "step 3" mentions an interstital page, is this necessary? Can't you simply count the click and issue the 301 instead of having a separate "Go" page?

Well that would be a better idea, but the store owner requires that the user is actually EXPLICITLY TOLD where they are going and the page stays there for a few seconds.


Featured Threads

Hot Threads This Week

Hot Threads This Month