I'd like to add some links to external websites and I need to track usage of these links. Instead of creating a direct link from a node, I'd like to do something like this:

http://mywebsiteurl.com/redirector.php?url=http://someexternalsite.com/s...

It's very important that the request is logged so I can monitor clicks.

What's the best way to do this? A homemade PHP script, .htaccess redirect, or a Drupal module (if one is available)?

Comments

barrett’s picture

I'd set up an exit page script and point links to it passing the destination url as a parameter. The exit page script could then give the user a message that they're leaving your site (if you want) and track the link accessed and whatever other data you want to record about the event.

External Links (http://drupal.org/project/extlink) might get you most of the way there, at least.

lemmax’s picture

Yes, I'm looking for something like an exit page. I presume that someone *must* have already done this and I'm hoping they may be willing to share their code. If not, I'll have a crack at coding this myself sometime next month. I don't think it will be too difficult.

lemmax’s picture

I forgot to mention that I'm already using extlink and very useful as it is it doesn't appear to have any option for tracking.

grobemo’s picture

I'm pretty sure Google Analytics can do this for you. Try the Google Analytics module.

lemmax’s picture

I'm already using Google Analytics but hadn't considered it as a solution to my problem. After your suggestion, I found this page:

http://forums.digitalpoint.com/showthread.php?s=45c2a6e7bacbde17a72aa196...

One of the posts suggests adding an onclick event to external links, like this:

onClick="javascript:urchinTracker ('/outgoing/linkname');"

which should then be tracked in Google Analytics.

It's certainly interesting, and I will give it a go on a handful of links just to see, but I'd much rather have a solution that neatly logs everything within Drupal.

grobemo’s picture

Even without adding that extra code, Google does some tracking of clicks. Log into Analytics, click on Content from the menu at left, and then click on "Site Overlay" under "Click Patterns." It may not be enough for your needs, but it's something.