Track Alexa rank, Facebook Like, Twitter Follower, and FeedBurner Subscriber counts

Site visibility history featured
  • Share:
  • share htpcBeginnerShare on FacebookhtpcBeginner on Google+Tweet It
  •   ¦  
    Pages: 1 2

Recently, I published a few posts on getting Facebook like count, Twitter followers count, FeedBurner Subscriber count, and Alexa Rank and Sites Linking in using simple PHP codes. Doing so has several advantages: replacing widgets (thereby improving page speeds) and displaying counts a simple formatted texts. It also provides the opportunity to combine subscriber / follower count to display a single count. I wanted to take this one step further and start recording these values in a MySQL database on a daily basis, thus building a history. There are a couple of major advantages (at least from my point of view) to doing this:

  1. I check my Facebook like count, Twitter followers count, FeedBurner subscribers count, Alexa rank, and Alexa sites linking in at least 2-3 times a week. Recording these values in a database allows me to visit a single page to check all these values (as shown in the picture below).
  2. One other major advantage is the ability to see how the visibility of your website is trending. For example, if you implement a giveaway for your readers if “Like” your Facebook fanpage, you can see what effect it had on your Facebook like count.
Track Alexa Rank

Alexa, Facebook, Twitter, and FeedBurner History


Creating a MySQL Table

First, you will have to create a table called wp_social_stats in your MySQL database. This is easy if you already know a little bit of MySQL and you have access to your database through phpMyAdmin or by other means. Remember that wp_social_stats should be table within your main database. Structure of the table is shown in the picture below:

Social Stats Table Structure

Social Stats Table Structure

Alternatively, through phpMyAdmin you can go to SQL tab of your database and type in the following query to create the table in one go. Change ENTER_YOUR_DATABASE_NAME to the name of your database.

Create Social Stats Table SQL Code

Create Social Stats Table SQL Code. Click here for the text version of the code.

PHP Code to Record Facebook, Twitter, FeedBurner, and Alexa Information

After you have created the wp_social_stats table within your MySQL database, it is now time to get the PHP code ready to record the Facebook, Twitter, FeedBurner, and Alexa rank values. Create a file named socialstats_record.php in the root folder of your site and copy the following contents to the file:

PHP Social Stats Record Code

PHP Social Stats Record Code

Download the full code using the download button below:

The following values have to be edited:

//Database details

//Get FeedBurner Subscriber Count

//Get Twitter Followers Count
$twurl = "";

//Get Facebook Like Count

//Get Alexa Rank and Sites Linking in
$source = file_get_contents('');

If you have trouble editing the above code refer: here, here, here, and here.

To visit the page go to (if you saved the file in your site’s root folder). From now on, every time the page is opened your social stats are recorded into the database.

Like this post? Share it and get Raspberry Pi OpenELEC Media Center 45-page eBook for Free!

Incoming Search Terms:

facebook like count database, facebooklike twitterfollower bbmsubscibe plugings for wordpress


  1. says

    Wonderful and lovelly explanations, This long days i use many plugin for wordpress, Now only i going to put hand in my coding, to implement my own stats report…

  2. says

    I was looking at the code for getting Alexa rank.

    There are three parameters – cli, dat and url. I can understand url but what are the other two? Please explain.

    Also is it ok/legal if i query for many sites?

    • says

      Sunil, The cli=10 is believed to provide the results in xml format and the dat parameter controls what information is received (example: rank, links in, etc.). You can get less or all information by modifying the letters in dat parameter. Also, i do not see a reason why this would be considered illegal. It is public information. This is all I am aware of. Hope it helps.

Leave a Reply

Review our comments policy.

Get your free comments avatar.


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>