Alexa, (an Amazon company), provides traffic data, global traffic rank and other information on websites. It ranks sites based on tracking information of user of its Alexa toolbar. Therefore, only webpages viewed by those with toolbar installed are counted, which makes the data biased. Furthermore, accuracy of low traffic websites may be questionable. Nevertheless, many advertisers and brokers use your Alexa rankings to approve or advertise on your website.
Recommended for you:
- My Top 5 Ways to Increase Alexa Traffic Rank
- Understand Alexa Parameters of your Blog that Advertisers note
In this post, I will explain how to use PHP to get Alexa rank of your blog or website using a simple PHP script. The number can be stored in cache or a database and displayed as simple formatted text. Compared to displaying Alexa widget, it also slightly improves page load speeds. So without further delay, here it goes.
PHP Code to Get Alexa Rank
The PHP code to get Alexa rank and sites linking in is pretty simple and straightforward:
Click here for a text version for the code that allows copying.
$source is the variable to hold the link to get information from Alexa about a specific site. Only edit you have to do is replace
shoutmeloud.com with your domain name. Alexa rank is now stored in the variable
$aresult and sites linking in stored in the variable
After you get alexa rank and sites liking in, you can display them as simple text using the following PHP code:
echo ‘Alexa Traffic Rank: ‘.$aresult’.'<br>';
echo ‘Alexa Sites Linking In: ‘.$alinksin;
This will output:
Alexa Traffic Rank: 4,881
Alexa sites Linking In: 2,750
Alexa Rank History
Although you may be able to get Alexa rank and more by other means, I like to record the data in a format I like. On my blog, I get Facebook like count and Alexa site rank and record them in a MySQL database daily to monitor the growth. For example, if you launched a blog in June 2012 and have recorded the Alexa rank in a database since then, you can use that data to quickly construct a history of your blog’s Alexa rank.
As you can see, having historical data helps one understand how the Alexa rank for their site is trending. If you make any changes / improvements to your blog then you have the data to see what impact it had on your subscribers count and Alexa rank.
So get Alexa rank using the above script, get creative, and find creative ways to use this PHP Alexa rank count Code. Please do not forget to share your idea with us in the comments sections.