If you had a list of URLs and you wanted to show which of them was more important than the others (by click-through), how would you gain the number of clicks for a given link so that you could sort them, possibly showing that some links are a thousand times more visited than the others?

The output could be:

1 : link1 : 10500

2 : link2 : 9200

3 : link3 : 8100

4 : link4 : 7000

5 : link5 : 250

6 : link6 : 100

7 : link7 : 20

  • Do you have the visit count in a database? – Aurelio De Rosa Nov 1 '11 at 14:39
  • The databases or some resources (that are objective and reliable and you would use for this task) should the part of the answer. – xralf Nov 1 '11 at 14:57

Well, after your comment, my opinion is that you should use Google Analytics. Using that tool, you are able to avoid any database and all the resource and space that this will require because of the large amount of data to track. Besides they surely can track info better than a single programmer can do. Finally, using Google Analytics you'll be able to order your pages by visit (DESC or ASC).


Consider using a URL shortening service such as bit.ly to get click data about a list of links. Here's how it would work:

  1. You'd use bit.ly shortened links for all links in your list.

  2. When a visitor clicks a bit.ly link, bit.ly increments the click count and stores it on their server.

  3. When a user visits your page – but before the list is displayed to them – your script would determine how many clicks each link has received using the /v3/clicks/ method from the bit.ly REST API, which returns click data about multiple bit.ly links you supply.

  4. You would sort this information by the total number of clicks, display the list, and optionally show the number of clicks for each link.

  5. You may also choose to cache the results of this request in your database and only request new data once an hour/day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.