Quantcast

How to Display Alexa Ranking on your website

Alexa Ranking, almost we all are worried about our website’s Alexa ranking when it comes to site popularity, SEO and marketing etc. Alexa is the site which maintains the traffic rank of all the websites and domains. Alexa Rank is an important factor to count when it comes to doing SEO of your website and marketing to bring traffic.

Many of us want to display Alexa ranking of our own or some other websites. It is quite easy to set up and works like a charm. I will go through with the basic steps to set this up using PHP and its couple of important functions. There is a simple XML output available by Alexa to grab the ranking details we need. You may simply copy the code below and test it.

The XML output URL goes like this

http://data.alexa.com/data?cli=10&url=<YOUR_DOMAIN>

In the above full url, YOUR_DOMAIN is the domain you will be using to get rank details for.

So if you try the above full URL with your own domain name in a browser, the XML output will be returned like below.

Two important values from the above output we need are Alexa global rank and country rank. We will grab them with the following PHP code.

The above code uses preg_match function in PHP which helps grabbing the necessary values we need.  So all you have to do is copy the above code and paste it in your php file. Simple echo $rank for global rank value or echo $rank_country for country’s specific rank.

I hope the above quick tutorial helps. Please leave your feedback and improvements in the comments below.

Looking for a quality hosting service? here are a few I suggest.
BlueHost | HostGator | Media Temple
Admin
Admin
Ali has been an entrepreneur in web, video and related technologies. Having worked with many business across the globe, Ali stands truly a great pillar in the business working with him.