Get two Page hits for a single link. ;)

Posted on Aug 21, 2010

Well, this was an idea from Kuntal Gupta. He asked me to make a redirecting script, so that if you pass any url to that page, it’ll redirect to that link surely, but will also give your site a hit.

Then i just thought, why not use JS to turn all the hyperlinks to such redirecting links. That way, whenever someone clicks a link on your site, you get an extra hit, irrespective of if the link is outgoing or in your site. :D

This is how it works -

Make a php file, name it redirect.php and save it in your root so that the location is, say, http://<your_url>/redirect.php and then edit the file and paste this code -

Save it.

Now add this Javascript snippet in your site’s header, inside the <head></head> block -

Now obviously you’d like to change the <your_url> part to your domain.

And thats it. Now reload your site, and you’ll see that all your hyperlinks have changed and now passes through the redirect.php file and gives you an extra hit every time you click a link.

Enjoy. :D